Redirect to Request Item instead of Order Status

MentZ
Kilo Expert

After the creation of a Request Item in the Portal, the user is redirected to the Order Status of the REQ, according to this:
find_real_file.png

 

What I want to achieve, its that the user should be redirected to the Request Item-page: sp?id=ticket&table=sc_req_item&sys_id=xxxxxxxxx

If I select 'ticket' in the Page Route Map, the user is redirected to the REQ-ticket and not the RITM-ticket.

I see there are various ways to achieve this, one of the alternatives is to clone the SC Catalog Item-widget, and change the client script as described here: How to dynamically redirect users to Requested Item page instead of SC Order Status page? - Customer...

But I'm not sure if this is the right way?

Any step by step instructions to do this would be highly appreciated.

1 ACCEPTED SOLUTION

1.) Enter sp_page.list in the Filter Navigator and hit Enter
find_real_file.png

2.) Enter sc_cat_item in the ID column and hit Enter
find_real_file.png

3.) Open the record shown in the screenshot

4.) Scroll down and click the column that holds the SC Catalog Item-Widget
find_real_file.png

5.) Copy the Sys ID of the Column Page
find_real_file.png

6.) Enter sp_instance.do in the Filter Navigator

7.) Continue on step 2 of my previous post where it explains to set the column with the help of the sys_id you just copied.

Hope this helps you 🙂

View solution in original post

10 REPLIES 10

Markus Kraus
Kilo Sage

In order for this to work, you have to create a new sibling widget instance next to the 'SC Catalog Item' Widget Instance on the 'sc_cat_item' Page:

  1. Copy the SysID of the Column
  2. Add a new Instance (sp_instance) and select the Column manually by filtering via sys_id on the magnifying glass
    find_real_file.png

  3. Order: 999
    Widget: SC Request Redirect (see below)
    Column: 1 (was set in step 2)

The 'SC Request Redirect'-Widget:
Name: SC Request Redirect
Server script:

(function() {
	if (input && input.action == 'get_redirect_info') {
		var scReqItemGr = new GlideRecord('sc_req_item');
		scReqItemGr.addQuery('request', input.request);
		scReqItemGr.setLimit(2); // only redirect of there is exactly one ritm in the request 
		scReqItemGr.query();
		
		if (scReqItemGr.next() && !scReqItemGr.hasNext()) {
			data.page = 'ticket';
			data.table = scReqItemGr.getRecordClassName();
			data.sys_id = scReqItemGr.getUniqueValue();
		} else {
			data.page = 'sc_request';
			data.table = 'sc_request';
			data.sys_id = input.request;
		}
		
		data.redirect_url = 'id=' + data.page + '&is_new_order=true&table=' + data.table + '&sys_id=' + data.sys_id;
	}
})();

Client controller: 

api.controller=function($rootScope, $location) {
	var c = this;
	
	// This event is emitted by the 'SC Catalog Item'-Widget once the item is submitted.
	// The 'auto_redirect' has to be set to 'false' (string!) int the instance options of the 'SC Catalog Item'-Widget
	$rootScope.$on('$sp.sc_cat_item.submitted', function($event , data) {
		if (data.table == 'sc_request') {
			c.server
				.get({ action: 'get_redirect_info' , request: data.sys_id })
				.then(function (response) { $location.search(response.data.redirect_url); });
		} else if (data.redirect_portal_url) {
			$location.search(data.redirect_portal_url);
		} else {
			$location.search('id=form&table=' + data.table + '&sys_id=' + data.sys_id);
		}
	});
};

 

Now you only have to set the following in the Instance for the 'SC Catalog Item' widget:
find_real_file.png

By default the 'SC Catalog Item' widget will automatically redirect to the sc_request page, but if you set auto_redirect to false, it will then submit the event captured by the 'SC Request Redirect' Widget.

Please let us know if this solved your question.

The best solution of all! Worked like a charm, non customized solution

You're welcome 🙂

If you do not need any further assistance, please mark the answer as the "solution" to close the thread.

Hello Markus,

Thank you for your answer. Can you please describe the steps as it was meant to be read by a newbie. I'm not really sure where to find the SysID of the Column. And what column.

Thank you in advance!