- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2026 07:36 PM
so your requirement is simply to show modal and 2 buttons
Proceed and Cancel
On click of Cancel take them to portal home?
On click of Proceed close the modal and let them submit form?
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2026 07:58 PM
@Ankur Bawiskar yes that is correct
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2026 08:08 PM
then try this and it will work in portal
function onLoad() {
var modalInstance;
spModal.open({
title: 'This is a test',
message: 'Please select cancel if you want to go back',
buttons: [{
label: 'Proceed',
value: 'agree',
primary: true // Makes this button visually prominent
}, {
label: 'Cancel',
value: 'disagree'
}]
}).then(function(result) {
// This function executes when a button is clicked
if (!result.primary) {
top.location.href = 'https://www.testing.com';
} else {
if (modalInstance) {
modalInstance.dismiss(); // Dismisses the modal
}
}
});
}
💡 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 || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2026 08:12 PM
works perfectly thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2026 07:45 PM
You have to set isolate script to false, then you can access the window object from this.
function onLoad() {
//Type appropriate comment here, and begin script below
if (typeof spModal !== 'undefined') {
if (g_scratchpad.isFormValid) {
return true;
}
var actionName = g_form.getActionName();
spModal.open({
backdrop: 'static',
keyboard: false,
message: 'Please select cancel if you want to go back',
title: 'This is a test',
buttons: [{
label: 'Cancel',
cancel: true
},
{
label: 'Proceed',
primary: true
}
]
}).then(
function onAgree(result) {
g_scratchpad.isFormValid = true;
g_form.submit();
return true;
},
function onDisagree(reason) {
setTimeout(function() {
this.location.href = 'https://www.testing.com';
}, 0);
return false;
}
);
g_scratchpad.isFormValid = false;
return false;
} else {
var gm = new GlideModal();
gm.setTitle('Error');
gm.renderWithContent('Something has gone wrong Prompt');
}
}To successfully submit with gform on the catalog item widget you also need to do something like this. Make sure you dont have two step checkout on the item
const $scope = angular.element("#sc_cat_item").scope()
$scope.data.sc_cat_item.item_action = "order";
g_form.submit()
//or maybe instead of submit use
$scope.triggerOnSubmit()