why confirm() is not working in ui action button
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2025 01:24 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2025 02:10 AM - edited 02-24-2025 02:11 AM
function reset_password() {
var answer = confirm("Are you sure you want to reset the password?");
if (answer) {
gsftSubmit(null, g_form.getFormElement(), 'reset_password');
}
}
if (typeof window == 'undefined'){
<Write your server side script here>
}
Try something like this.
Have your server side script after the client side. Set redirect URL as well.
If my response helped please mark it correct .
Thanks and regards
Bharath
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2025 02:33 AM
no I didn't worked unable to save it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2025 08:58 AM
Having the exact same issue, I think everyone else in the thread is misdiagnosing. Anytime you try to use confirm
eg. I change my line from
workflowconfirm = true
to
workflowconfirm = confirm("Confirm?")
when you go to press save the ui action is not saved, and you are shown this screen instead. Pressing the back arrow will return you to the ui action but without any of your changes saved.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2025 01:42 AM
For ServiceNow i recommend using GlideModal instead of JavaScript Confirm.
Here is link how how GlideModal can be used with examples:
https://davidmac.pro/posts/2022-02-08-glidemodal/
For your case you would need to use in your UI Action (Client Type) this:
function resetPassword() {
var gm = new GlideModal('password_reset_confirm');
gm.setTitle('Password Reset Confirmation');
// Optionally pass any needed parameters:
// gm.setPreference('incident_sys_id', g_form.getUniqueValue());
gm.render();
}
and then create UI Page.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2025 01:45 AM
Hi @Jithender123,
Please provide a screenshot of the UI action script component to better understand the issue.
Regards,
Somu