Show popup on Submit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2025 09:04 PM
I want to show a confirm popup when incident is cancelled.
once state cancelled is selected, popup should appear where some cancellation policy is mentioned and on top of that resolution code should be selected from the popup. If user selects 'Yes', incident should be cancelled and if No, page should reload with old state values
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2025 09:26 PM
create a new client script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '' || newValue == oldValue) {
return;
}
// Check if state is set to 'Cancelled' (Replace with the correct value for 'Cancelled' state)
if (newValue == '8') { // '8' is typically the value for "Cancelled", confirm in your instance
var dialog = new GlideDialogWindow('glide_confirm_dialog');
dialog.setTitle('Confirm Cancellation');
dialog.setBody(
'<p>Please review the cancellation policy before proceeding.</p>' +
'<label for="resolution_code">Select Resolution Code:</label>' +
'<select id="resolution_code">' +
'<option value="policy_violation">Policy Violation</option>' +
'<option value="duplicate">Duplicate Incident</option>' +
'<option value="resolved_elsewhere">Resolved Elsewhere</option>' +
'</select>',
false, // no escape HTML
true // show Cancel button
);
dialog.setWidth(400);
dialog.setHeight(250);
// "Yes" button action
dialog.on('execute', function() {
var resolutionCode = document.getElementById('resolution_code').value;
if (resolutionCode) {
g_form.setValue('close_code', resolutionCode); // Set Resolution Code
g_form.save(); // Save the form with the selected resolution code
} else {
alert("Please select a resolution code before proceeding.");
}
});
// "No" button action - Reloads the page with previous state
dialog.on('cancel', function() {
g_form.setValue('state', oldValue); // Revert to old state
g_form.reload(); // Reload the form
});
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2025 09:36 PM
you can use UI page and invoke it from onChange client script
what did you start with and where are you stuck?
GlideDialogWindow: Advanced Popups Using UI Pages
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
‎03-02-2025 01:36 AM
Thanks for the reply.
I was using confirm function. However that will not satisfy the requirement.
Basically when user selects cancel state from dropdown then resolution code and resolution notes fields are mandatory. At the same time I want to show popup about the cancellation policy. So, in the popup I want user to select the resolution code and resolution note and if yes selects 'Yes' then incident should be cancelled and if he selects 'No' page should be reloaded
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2025 03:48 AM
yes confirm button won't help.
You need to use UI pages and then show the select box inside HTML
Please check the link and enhance your code.
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