- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 02:34 AM
Hi,
There is OOB Ui action for interaction table "Close". when we click on that close button it needs to make "assigned to" mandatory.
can anyone let me know, how can i make changes on here.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 03:40 AM
Please remember this is an OOB UI Action and if you update it then during upgrade it will be skipped
is it for native or workspace that you want to make it mandatory?
Client Script:
function closeInteraction() {
if(g_form.getValue('assigned_to') == ''){
g_form.addInfoMessage('Please fill assigned to');
g_form.setMandatory('assigned_to', true);
return;
}
var dialog = new GlideModal("close_confirmation");
var msg = getMessage('Confirmation');
dialog.setTitle(msg);
dialog.setPreference("sys_id", g_form.getUniqueValue());
dialog.render();
}
Workspace client script:
function onClick(g_form) {
getMessage("Are you sure you want to close this interaction?", function(msg) {
if (g_form.getValue('assigned_to') == '') {
g_form.addInfoMessage('Please fill assigned to');
g_form.setMandatory('assigned_to', true);
return;
}
g_modal.confirm(getMessage("Confirmation"), msg, function(confirmed) {
if (confirmed) {
g_form.setValue('state', 'closed_complete');
g_form.save();
}
});
});
return false;
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 03:23 AM
If I am not wrong, it looks like some changes have been done in UI Action, the OOTB code is different. Please make changes and then add your condition
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 03:40 AM
Please remember this is an OOB UI Action and if you update it then during upgrade it will be skipped
is it for native or workspace that you want to make it mandatory?
Client Script:
function closeInteraction() {
if(g_form.getValue('assigned_to') == ''){
g_form.addInfoMessage('Please fill assigned to');
g_form.setMandatory('assigned_to', true);
return;
}
var dialog = new GlideModal("close_confirmation");
var msg = getMessage('Confirmation');
dialog.setTitle(msg);
dialog.setPreference("sys_id", g_form.getUniqueValue());
dialog.render();
}
Workspace client script:
function onClick(g_form) {
getMessage("Are you sure you want to close this interaction?", function(msg) {
if (g_form.getValue('assigned_to') == '') {
g_form.addInfoMessage('Please fill assigned to');
g_form.setMandatory('assigned_to', true);
return;
}
g_modal.confirm(getMessage("Confirmation"), msg, function(confirmed) {
if (confirmed) {
g_form.setValue('state', 'closed_complete');
g_form.save();
}
});
});
return false;
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 08:40 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 09:01 PM
Hi @PRAGHATIESH S ,
Use below code in workspace client script.
getMessage("Are you sure you want to close this interaction?", function (msg) {
g_modal.confirm(getMessage("Confirmation"), msg, function (confirmed) {
if (confirmed) {
// Check if "Assigned to" has a value
if (!g_form.getValue('assigned_to')) {
g_form.addErrorMessage("The 'Assigned to' field is mandatory. Please provide a value.");
g_form.showFieldMsg('assigned_to', "This field is mandatory.", 'error');
return false;
}
// Proceed to close the interaction
g_form.setValue('state', 'closed_complete');
g_form.save();
}
});
});
return false;
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-30-2024 10:19 PM
You need to create a data policy here. Do try and let me know