Knowledge sharing about UI action.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2024 03:28 AM
Earlier, I posted a question regarding a UI action where the form should redirect to the Service Portal based on the user's choice between the OK and Cancel buttons in the confirmation dialog.
After trying various approaches, I've found the solution, which I believe can be helpful for others facing a similar challenge in the future.
Below is the code snippet that achieves the redirection based on the user's selection:
function CheckConfirm() {
var answer = confirm("Do you want to revoke the certificate? If Yes, click OK. To proceed with cancelling the certificate, click Cancel.");
if (answer != true) {
alert("Answer not true");
gsftSubmit(null, g_form.getFormElement(), 'cancel_renewal');
} else {
alert("Service portal endpoint trigger");
parent.window.open('https://*********.service-now.com/sp?id=sc_cat_item&sys_id=293403d22b51e100e587553069da1575', '_blank');
gsftSubmit(null, g_form.getFormElement(), 'cancel_renewal');
}
}
if (typeof window == 'undefined') {
current.state = 4; // cancel the record.
current.work_notes = "The certificate has been set to cancelled.";
current.update();
action.setRedirectURL(current);
gs.addInfoMessage('Cancelled.');
}
Thanks.