- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi,
function onClick() {
var comments = g_form.getValue("comments");
if (!comments) {
alert('The "Additional comments" field must be filled in before the transtitioning to Canceled');
return false;
}
g_modal.confirm('Confirmation', 'Are you sure you want to cancel this incident?', {
cancelTitle: 'No', // Custom label for the 'No' button
confirmTitle: 'Yes' // Custom label for the 'Yes' button
}).then(function() {
// Executes if user clicks Yes
g_form.setValue('incident_state', '8'); // Cancelled
g_form.setValue('state', '8');
g_form.submitAction("cancel_incident"); // Trigger server-side UI Action
}, function() {
// Executes if user clicks No or closes the dialog
});I have written the workspace client script for yes and no button while clicking upon cancel ui action button.
The popup up is coming with yes and no but clicking on yes or no it is not working.
Anupam
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @Sandeep8987
Check this code
function onClick() {
var comments = g_form.getValue("comments");
if (!comments) {
alert('The "Additional comments" field must be filled in before transitioning to Canceled');
return false;
}
g_modal.confirm(
'Confirmation',
'Are you sure you want to cancel this incident?',
function(confirmed) {
if (confirmed) {
g_form.setValue('state', '8');
g_form.save();
}
}, {
"cancelTitle": "No",
"confirmTitle": "Yes"
});
return false;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @Sandeep8987
Check this code
function onClick() {
var comments = g_form.getValue("comments");
if (!comments) {
alert('The "Additional comments" field must be filled in before transitioning to Canceled');
return false;
}
g_modal.confirm(
'Confirmation',
'Are you sure you want to cancel this incident?',
function(confirmed) {
if (confirmed) {
g_form.setValue('state', '8');
g_form.save();
}
}, {
"cancelTitle": "No",
"confirmTitle": "Yes"
});
return false;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Thanks a lot @Shruti , the code is working fine now.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
try this
function onClick(g_form) {
var comments = g_form.getValue("comments");
if (!comments) {
alert('The "Additional comments" field must be filled in before transitioning to Canceled');
return false;
}
g_modal.confirm('Confirmation', 'Are you sure you want to cancel this incident?', {
cancelTitle: 'No',
confirmTitle: 'Yes'
}).then(function() {
// User clicked Yes
g_form.setValue('incident_state', '8');
g_form.setValue('state', '8');
g_form.submitAction("cancel_incident");
}, function() {
// User clicked No or closed the dialog
// Do nothing, just exit
});
}
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader