- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2025 02:16 AM
Hello all,
On the Incident form, when the user is trying to save the form after the state has been moved to Resolved, then I need to display an alert with Yes or No, instead of Ok and Cancel using confirm("Validated with user?");
So, can someone let me know how can we do this?
Regards,
Lucky
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2025 02:37 AM - edited 05-13-2025 02:40 AM
business rule can't show you dialog box as dialog box only works from client side code
I suggested to use that dialog box code in the Close button
Did you try that approach?
Don't create any client script
function moveToClosed() {
var dialog = new GlideModal('glide_modal_confirm', true, 300);
dialog.setTitle('Confirmation');
dialog.setPreference('body', 'Validated with user?');
dialog.setPreference('focusTrap', true);
dialog.setPreference('onPromptComplete', doComplete);
dialog.setPreference('onPromptCancel', doCancel);
dialog.render();
function doComplete() {
callback(true);
g_form.setValue("state", "3");
gsftSubmit(null, g_form.getFormElement(), "state_model_move_to_closed");
}
function doCancel() {
callback(false);
return false;
}
}
if (typeof window == 'undefined')
setRedirect();
function setRedirect() {
current.update();
action.setRedirectURL(current);
}
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
05-13-2025 02:25 AM
then add this code of dialog window in that "Close" ui action
if it's server side then make it combination of client+server
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
05-13-2025 02:35 AM
Hello Ankur and SUmanth,
IS there a way to do this from Business rule?
Because we have Save button on the Change form and as well as Close button,
So, can we create a BR, When to Run: State changes to Closed
like this..
Regards,
Lucky
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2025 02:37 AM - edited 05-13-2025 02:40 AM
business rule can't show you dialog box as dialog box only works from client side code
I suggested to use that dialog box code in the Close button
Did you try that approach?
Don't create any client script
function moveToClosed() {
var dialog = new GlideModal('glide_modal_confirm', true, 300);
dialog.setTitle('Confirmation');
dialog.setPreference('body', 'Validated with user?');
dialog.setPreference('focusTrap', true);
dialog.setPreference('onPromptComplete', doComplete);
dialog.setPreference('onPromptCancel', doCancel);
dialog.render();
function doComplete() {
callback(true);
g_form.setValue("state", "3");
gsftSubmit(null, g_form.getFormElement(), "state_model_move_to_closed");
}
function doCancel() {
callback(false);
return false;
}
}
if (typeof window == 'undefined')
setRedirect();
function setRedirect() {
current.update();
action.setRedirectURL(current);
}
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
05-13-2025 03:03 AM
this worked for me
Ensure you add the closure details before closing the CHG
function moveToClosed() {
var dialog = new GlideModal('glide_modal_confirm', true, 300);
dialog.setTitle('Confirmation');
dialog.setPreference('body', 'Validated with user?');
dialog.setPreference('focusTrap', true);
dialog.setPreference('onPromptComplete', doComplete);
dialog.setPreference('onPromptCancel', doCancel);
dialog.render();
function doComplete() {
g_form.setValue("state", "3");
gsftSubmit(null, g_form.getFormElement(), "state_model_move_to_closed");
}
function doCancel() {
return false;
}
}
if (typeof window == 'undefined')
setRedirect();
function setRedirect() {
current.update();
action.setRedirectURL(current);
}
Output:
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
05-19-2025 10:39 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