Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

Is there a way to control the redirect after catalog item submit in Service Portal with a client script?

patricklatella
Mega Sage

Hi all, I've got a catalog item that I need to control the redirect after it's submitted in Service Portal.  I need this to work much like "producer.redirect", but in an onSubmit catalog client script on a catalog item (not a record producer)...I only need this redirect if certain variable values are set...that's why I want to use the onSubmit catalog client script.  Is this possible?  I'm seeing some threads that suggest using:

var URL = "sp?id=index;
top.window.location = URL;

which kind of works, but I'm seeing some comments not to use this, and when you click "Submit" I get this first, and then it redirect correctly.

find_real_file.png

 

I only need to redirect for one specific scenario, and I'd like to not clone the SC Catalog Item widget to do it.  Any thoughts?

1 ACCEPTED SOLUTION

Weird
Giga Sage
var URL = "sp?id=index";

top.window.onbeforeunload = null;
top.window.onunload = null;
top.window.location = URL;


You could try this. I have no idea if it will work, but it was one of the options provided in 
Here by MB

I recently tackled this issue myself on record producer so I was interested in what would be needed on a catalog item. Let me know if it works.

View solution in original post

9 REPLIES 9

Ankur Bawiskar
Tera Patron

Hi Patrick,

So if user is redirected to that url; the record producer won't submit though; is that expected behavior?

Also I believe that alert you are getting from browser since you are setting some field values and moving away from that page

Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

Hi Ankur,

thanks for the response.  This isn't a record producer, it'a a catalog item.  And with that script I put in my post it's working correctly, it just is first showing this:

find_real_file.png

then after you click "Leave" it redirects correctly.  But I need it work without this alert message.

Weird
Giga Sage
var URL = "sp?id=index";

top.window.onbeforeunload = null;
top.window.onunload = null;
top.window.location = URL;


You could try this. I have no idea if it will work, but it was one of the options provided in 
Here by MB

I recently tackled this issue myself on record producer so I was interested in what would be needed on a catalog item. Let me know if it works.

Hi Joni,

that works!  Submit goes through without that alert and user is redirected to the URL I set.  Thanks!