Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

How to redirect user straight to RITM after creating Catalog Request

Alon Grod
Tera Expert

Hi,

How can I redirect the user straight to RITM instead of going first to REQ and then to related RITM. When the user create a new Catalog Request from the Service Operation Workspace, he redirected to the REQ and then he needs to go to related record and click on the associated RITM. I want to send him straight to the RITM.

 

Screenshot 2023-08-10 at 17.08.39.png

 

Client script:

api.controller=function($scope , $location) {
	/* widget controller */
	var c = this;

	//$sp.service_catalog.cart.submitted - .request_method
	//$sp.sc_cat_item.submitted

	//SC Catalog Item widget emits an event when a record is succesfully submitted
	//Catch the server response and capture a redirect

	$scope.$on("$sp.sc_cat_item.submitted", function($event , $data){

		console.log($event);
		console.log($data);

		//Get Details on the RITM
		if($data.hasOwnProperty('table') && $data.table === "sc_request"){
			$scope.server.get({action: "get_record" , request_id : $data.sys_id}).then(function(response){
				console.log(response.data);
				//Only Redirect to ritm if
				//Global redirect override is enabled
				//Item is configured to redirect
				if(!response.data.error && response.data.ritm_redirect == "true"){
					$location.search("id=" + c.options.page_id + 
													 "&is_new_order=true&table=" + response.data.table + 
													 "&sys_id=" + response.data.ritm_id);
					return;
				} else {
					$location.search('id=sc_request&is_new_order=true&table=sc_request&sys_id=' + $data.sys_id);
				}

			})
		}

		//Handle Record Producers
		if($data.hasOwnProperty('redirect_portal_url') && $data.redirect_portal_url !== ''){
			$location.url(data.redirect_portal_url);
			return;
		}

		//Fallback to a record
		$location.search("id=ticket&is_new_order=true&table=" + $data.table + "&sys_id=" + $data.sys_id);

	})
};

  

Server Script: 

(function() {
 
	var catItemProps = {
		"show_add_cart_button" : options.show_add_cart_button,
		"auto_redirect" : "false"
	}
	
	data.catItemWidget = $sp.getWidget('widget-sc-cat-item-v2' , catItemProps);
	data.systemProperties = {
		"redirect_override" : gs.getProperty('x_295070_req2ritm.redirect_override' , 'false')
	}
	
	if(input && input.action == "get_record"){
		var scReqItemGR = new GlideRecord('sc_req_item');
		scReqItemGR.addQuery('request' , input.request_id);
		scReqItemGR.query();
		if(scReqItemGR.next() && scReqItemGR.getRowCount() == 1){
			data.ritm_id = scReqItemGR.getUniqueValue();
			data.table = scReqItemGR.getTableName();
			data.ritm_redirect = data.systemProperties.redirect_override === 'false' ? scReqItemGR.cat_item.x_295070_req2ritm_redirect + '' : 'true';
			data.error = false;
		} else {
			data.error = true;
		}
		
	}

})();
3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@Alon Grod 

I believe it's enough to show them REQ. they need not know the further details.

If you entertain this requirement customer will ask you to redirect user to catalog task etc.

Check this link has solution

How to redirect user to RITM after submitting catalog item 

sharing additional links

Send user to RITM instead of REQ when submitting a catalog item 

Redirect Submit to RITM instead request on Service Portal 

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

Alon Grod
Tera Expert

Alon Grod
Tera Expert

@Community Alums  @Brad Tilton