Service Catalog Request - Re-direct to external URL

simon4647
Tera Contributor

Hi,

 

I'm trying to create a catalog request which re-directs the user to an external URL. I want the code to run "On Submit" so that the request is recorded and preferably the URL opens in a popup window. I currently have this (in a Catalog UI Policy - I've tried several Client Scripts but to no avail)

 

(function executeRedirectAction(current, previous) {
    // Replace 'yourURL' with the URL you want to redirect to
    var redirectURL = 'https://myUrl.com';
    gs.addInfoMessage('Redirecting to ' + redirectURL);
    action.setRedirectURL(redirectURL);
})(current, previous);
2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@simon4647 

you can use onSubmit catalog client script and use Synchronous Ajax so that the request is submitted and it opens url in new tab

UI policy script is client side so gs object won't work there and also action object won't work

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

simon4647
Tera Contributor

Hi Ankur, thanks for your speedy response.

Would something like the following be appropriate?

 

function onSubmit() {

    // Replace 'https://example.com' with the URL you want to open

    var newURL = 'https://example.com';

   

    // Open the new URL in a new tab

    window.open(newURL, '_blank');

   

    // Return true to allow the form submission to proceed

    return true;

}