- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11 hours ago
I am tryign to show a modal confirm message when deleting the records I am using g_modal it is not working
Regards,
APV Babu
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10 hours ago
Hi @APV Babu ,
you’re trying to show a confirmation modal before deleting a record, but g_modal isn’t working.
g_modal only works in UI Builder or Now Experience, not in classic UI.
Classic UI (use gsftConfirm)
function onClick(g_form) { if (g_user.userID != g_form.getValue('created_by')) { alert('Only the assigned user can end this action.'); return; } var msg = "Are you sure you want to take this action?"; gsftConfirm(msg, function(confirmed) { if (confirmed) { g_form.setValue('state', 'closed_complete'); g_form.save(); } }); return false; }
UI Builder / Now Experience (use g_modal.confirm)
g_modal.confirm('Are you sure?', 'Confirmation', function(confirmed) { if (confirmed) { g_form.setValue('state', 'closed_complete'); g_form.save(); } });
Summary:
Classic UI → gsftConfirm()
UI Builder → g_modal.confirm()
If my response helped, please mark it as the accepted solution so others can benefit as well.
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
9 hours ago
Hi @APV Babu
Below will help you to understand!!
Confirm Modals in ServiceNow
UI Type | Supported Method | Example | Notes |
---|---|---|---|
Classic UI (forms, lists) | gsftConfirm() | ```javascript | |
function onClick(g_form) { | |||
if (g_user.userID != g_form.getValue('created_by')) { |
}
var msg = "Are you sure you want to take this action?";
gsftConfirm(msg, function(confirmed) {
if (confirmed) {
g_form.setValue('state', 'closed_complete');
g_form.save();
}
});
return false;
}
| **UI Builder / Now Experience** | `g_modal.confirm()` | ```javascript
g_modal.confirm('Are you sure?', 'Confirmation', function(confirmed) {
if (confirmed) {
g_form.setValue('state', 'closed_complete');
g_form.save();
}
});
``` | Works only in **UI Builder / Workspace** components that support the `g_modal` API. |
---
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
YouTube: https://www.youtube.com/@learnservicenowwithravi
LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10 hours ago
Hi @APV Babu ,
you’re trying to show a confirmation modal before deleting a record, but g_modal isn’t working.
g_modal only works in UI Builder or Now Experience, not in classic UI.
Classic UI (use gsftConfirm)
function onClick(g_form) { if (g_user.userID != g_form.getValue('created_by')) { alert('Only the assigned user can end this action.'); return; } var msg = "Are you sure you want to take this action?"; gsftConfirm(msg, function(confirmed) { if (confirmed) { g_form.setValue('state', 'closed_complete'); g_form.save(); } }); return false; }
UI Builder / Now Experience (use g_modal.confirm)
g_modal.confirm('Are you sure?', 'Confirmation', function(confirmed) { if (confirmed) { g_form.setValue('state', 'closed_complete'); g_form.save(); } });
Summary:
Classic UI → gsftConfirm()
UI Builder → g_modal.confirm()
If my response helped, please mark it as the accepted solution so others can benefit as well.
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10 hours ago
what's your actual business requirement here?
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
9 hours ago
Hi @APV Babu
Below will help you to understand!!
Confirm Modals in ServiceNow
UI Type | Supported Method | Example | Notes |
---|---|---|---|
Classic UI (forms, lists) | gsftConfirm() | ```javascript | |
function onClick(g_form) { | |||
if (g_user.userID != g_form.getValue('created_by')) { |
}
var msg = "Are you sure you want to take this action?";
gsftConfirm(msg, function(confirmed) {
if (confirmed) {
g_form.setValue('state', 'closed_complete');
g_form.save();
}
});
return false;
}
| **UI Builder / Now Experience** | `g_modal.confirm()` | ```javascript
g_modal.confirm('Are you sure?', 'Confirmation', function(confirmed) {
if (confirmed) {
g_form.setValue('state', 'closed_complete');
g_form.save();
}
});
``` | Works only in **UI Builder / Workspace** components that support the `g_modal` API. |
---
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
YouTube: https://www.youtube.com/@learnservicenowwithravi
LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
8 hours ago
Hi Ravi can we customize GlideModal Buttons instead of 'OK' and 'Cancel'
Regards,
APV Babu