Service Portal Service Catalog Item widget redirect to custom page based on item

Katie A
Mega Guru

I am using the SC Item widget [widget-sc-cat-item-v2] in the Service Portal on the Kingston release.

After the user submits the form, I want to redirect the user to a custom page instead of the default redirect location.

Also, I want to set the redirect based on the item. In other words, most items will redirect to the default location, whereas other items must redirect to the custom confirmation page.

Is there a way to do this by passing in the desired redirect location without modifying the out-of-box widget?

Or if the widget does need to be modified, what is the best way to do this with minimal code revisions?

Thanks!

4 REPLIES 4

Mike Patel
Tera Sage

I did something similar while back but it was for only 1 item so I added onSubmit Catalog Client script. You can add this to all item that you want to redirect to specific url.

 

function onSubmit() {
	top.window.setTimeout(fun2,2000);
	function fun2() {
		top.window.location = "sp?id=xxxxx";

	}
}

subhashuniyal
Tera Contributor

The widget expects the number field of the created record, which will not be there in case of custom table. I cloned the OOB widget and commented line number 238 in the client controller and the redirect worked.

 

find_real_file.png

ericgilmore
Tera Guru

Aaaaand the answer was??

ColeM
Tera Expert

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0656003

INFO FROM ABOVE SOURCE

 

  1. Widget Instance level (SC Catalog Item widget) Catalog item redirection
    To redirect all users to a specific page after each catalog item submission:
    • Go to /sp?id=sc_cat_item.
    • Press Ctrl + Right Click and select Instance Option.
    • For the option Successful Order Page, choose the desired page.
    • Note: In the same widget instance, there is an option to add a default page. Choose the desired table in the Successful Order Table field.
    • Once you have successfully configured these, you should be able to click on the link generated in the success message to navigate to the desired page/record.
    • If you want users to auto-redirect to the configured pages on submission, check the Auto Redirect on Successful Order option.
  2. Record producer script redirection
    • If you are looking for specific page redirection based on a script for Record Producer, use this example script:
      producer.portal_redirect = "?id=sc_home"