Dialog box is not prompted when UI action is clicked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2024 12:46 PM - edited 06-17-2024 08:29 PM
Hello Experts,
I am using below script in UI Action to show a pop up confirmation with different verbiage based on the current state. but when clicked on button no action is being taking place.
Script:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2024 10:52 PM
Hi,
Can you try with the below code and test again.
function onClick() {
// Definition of the callback function for OK button
var myActionCallbackOK = function() {
submitNow();
};
// Definition of the callback function for Cancel button
var myActionCallbackCancel = function() {
cancelNow();
};
var dlgBody = 'Are you sure you want to approve the Task?';
if (current.state == '2') {
dlgBody = 'Are you sure you want to approve the Task?';
} else {
dlgBody = 'PR will be removed. Are you sure you want to approve the ABR Task?';
}
var dlgClass = window.GlideModal || GlideDialogWindow;
var dlg = new dlgClass('glide_confirm_standard');
dlg.setTitle(dlgBody);
dlg.setPreference('onPromptComplete', myActionCallbackOK);
dlg.setPreference('onPromptCancel', myActionCallbackCancel);
dlg.render();
function submitNow() {
g_form.setValue('state', '6');
g_form.submit();
}
function cancelNow() {
// Closes the window by default, can be empty
}
}
Please mark this helpful if it works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2024 06:03 AM
Hello,
I tried it, no luck. any other input?
Thanks,
Rocky.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2024 06:08 AM
your UI action is client side; so current won't work
please use g_form.getValue() to get the state value and then compare
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