
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2018 12:25 AM
I Have a Catalog Item which prompts (using an Onload Client Script) for Agreement or Cancel to a Terms and Conditions. When a User Clicks 'Cancel' I want it to redirect to my portal homepage. Can I simply do this in the Catalog Client Script? If not how do I go about doing this?
NOTE: I'm a bit new to javascript and in fact ServiceNow, but I have this so far:
function onLoad() {
//Type appropriate comment here, and begin script below
spModal.open({
message: 'By clicking OK below you are signifying that you have understood the terms etc. etc. etc.',
title: 'Terms and Conditions',
buttons: [{label: 'Agree', primary:'true'},{label: 'Cancel'}],
});
}
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2018 02:33 PM
Hi,
We have something like this working but needed to utilize a service portal widget.
Catalog Client Script:
function onLoad() {
spModal.open({
message: 'my big message',
title: 'Terms and Conditions',
buttons: [
{label: 'Agree', primary: true},
{label: 'Cancel', cancel: true}
]
}).then(function() {
}, function() {
spModal.open({widget: 'widget-id'});
});
}
and for your portal widget you will need to a client controller somewhat like below:
function($window) {
/* widget controller */
var c = this;
$window.location.href = "sp?id=sc_home";
}
This should redirect them back to the page they were on before they clicked the catalog item.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2018 01:18 AM
Hi,
from g_form you cant so easily redirect to another URL. There is an setRedirect(url) method but its server side and can be used in UI Actions for example. Still you can use base JS methods as
document.location.assign('https://developer.mozilla.org/en-US/docs/Web/API/Location.reload');
This is not very good approach though.
I have a question for your item - spModal is service portal method so its available for widgets usually. If you use your catalog item to be shown in the portal, I am not very sure if it will work as expected - at least it will start to mix the scope and digest cycle.
Why not use the GlideDialogWindowAPI - https://developer.servicenow.com/app.do#!/api_doc?v=london&id=c_GlideDialogWindowAPI ?
What exactly you are trying to achieve btw ?
Cheers,
Joro

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2018 04:01 PM
Thanks Joro, we simply have a catalog item for people to request approval (with a business reason) for email to be setup on their personal device. After approval, this creates an REQ and RITM, runs a workflow that adds the required AD groups, and creates a notification for the user to setup what they require at their end.
The pop up we require is the Terms and Conditions and we need the user to Agree (which lets them fill in and submit the catalog item form) or Cancel (which should redirect them to the portal homepage).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2018 02:33 PM
Hi,
We have something like this working but needed to utilize a service portal widget.
Catalog Client Script:
function onLoad() {
spModal.open({
message: 'my big message',
title: 'Terms and Conditions',
buttons: [
{label: 'Agree', primary: true},
{label: 'Cancel', cancel: true}
]
}).then(function() {
}, function() {
spModal.open({widget: 'widget-id'});
});
}
and for your portal widget you will need to a client controller somewhat like below:
function($window) {
/* widget controller */
var c = this;
$window.location.href = "sp?id=sc_home";
}
This should redirect them back to the page they were on before they clicked the catalog item.