UI action displays a dialog box with 'Yes' and 'No' buttons
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
I need to create an onSubmit client script that displays a dialog box with 'Yes' and 'No' buttons instead of the default 'Cancel' and 'OK'. If the user selects 'Yes', the state should change to 'Closed'. If the user selects 'No', the state should remain unchanged."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
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
a month ago
This solution might help you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
onSubmit Client Script with Custom Yes/No Dialog
// Table: [Your Table]
// Type: onSubmit
function onSubmit() {
// Prevent form submission initially
return false;
}
function onLoad() {
// Add this to onLoad to handle the dialog
g_form.addButton('close_ticket', 'Close Ticket', function() {
var dialog = new GlideModal('glide_confirm_standard');
dialog.setTitle('Confirm Action');
dialog.setBody('Are you sure you want to close this ticket?');
// Custom Yes/No buttons
dialog.addButton('Yes', function() {
g_form.setValue('state', 'closed'); // Set to closed state value
g_form.save();
dialog.destroy();
});
dialog.addButton('No', function() {
dialog.destroy(); // Just close dialog, no state change
});
dialog.render();
});
}
Alternative: Simple Confirm Approach
// Type: onSubmit
function onSubmit() {
if (confirm('Do you want to close this ticket?')) {
g_form.setValue('state', 'closed');
return true; // Submit form
}
return false; // Cancel submission
}
Recommendation: Use the simple confirm approach for quick implementation - it's more reliable and precise.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.