Redirect Submit to RITM instead request on Service Portal

BenG
Tera Guru

Hi,

When I "Submit" a Service catalog item on service Portal, the request page (sc_request) opens.

I would like a rediction of this submit to ritm page instead sc_request page.

I know I have to modifiy the clone of the widget "SC Catalog Item" but I don't know how.

Any idea ?

Thanks for your help,

1 ACCEPTED SOLUTION

oharel
Kilo Sage

Hi there,

I am not sure it is relevant for you anymore, but still, in case someone else needs it, this is what worked for me:

1. Clone the SC Catalog Item widget

2. change the client script:

(look for "$location.search('id=sc_request&is_new_order..." around line 510)

 

//$location.search('id=sc_request&is_new_order=true&table=sc_request&sys_id=' + a.sys_id); //--> we do not want to redirect to the sc_request page
c.data.myrequest = a.sys_id;
c.server.update();
setTimeout(function(){
var ritmid = c.data.ritmId;
								$location.search('id=form&table=sc_req_item&view=ess&sys_id=' + ritmid);
}, 400);
}

3. and in the server script, arounbd line 11, right after return;, add

if(input) {
if(input.myrequest != undefined) {
   var ritm = new GlideRecord('sc_req_item');
   ritm.addQuery('request',input.myrequest); //from line 514 in the client script ritm.query();
//If exactly one RITM is returned, pass to the Client Controller to redirect user
  if(ritm.next()) {
	data.ritmId = ritm.getUniqueValue();
 }
}

That's it.

harel

 

View solution in original post

20 REPLIES 20

Not sure what you mean.

Once submitted, the user is redirected...

Hi, I was wondering where exactly the code in the server script goes? I've tried this solution but it didn't work, and I'm wondering if i put the server code in the wrong place.

 

Thanks very much,

Sarah

Thank you for the posts. I used your code to come up with my solution. I cloned the SC Order Guide. The requirement was to submit to the RITM.

 

Client Script:

//Redirect to the RITM summary page after submit
c.server.update(); //Need to save Request for RITM to generate
c.data.myrequest = $scope.data.result.request_id; //Capture sys_id of Request
setTimeout(function() {
  var ritmid = c.data.ritmId; //Assign sys_id of RITM
  //New Redirection
  $location.search('id=esp_ticket&table=sc_req_item&sys_id=' + ritmid); //Display RITM screen after submit
  }, 400);
 
Server Script:
//Find the RITM sys_id from the Request sys_id
if(input){
  var ritm = new GlideRecord('sc_req_item');
  ritm.addQuery('request',data.myrequest);
  ritm.query();
  if(ritm.next()){
  data.ritmId = ritm.sys_id.toString();
  }
}

Hi @lalbertelli , how are you?!

 

Could you give me more information? Please!

 

1) You cloned the "SC Order Guide" widget.
2) You included the scripts mentioned above in the client and server! But on which lines?
3) After that, did you create a new page and add the cloned widget?

4) Was it necessary to create a "Page Route Map" (Redirecting to the new page with the widget you cloned)?

 

Thanks so much for your attention!

 

Note: I'm asking because I tried to do what you did, but it didn't work.

oharel
Kilo Sage

Right at the beginning, below the line 6

// populate the 'data' variable with catalog item, variables, and variable view
(function() {

var embeddedWidgetOptions = ['auto_redirect', 'requested_for_id', 'requested_for_display'];
if (input && input.action == "from_attachment")
return;

 

--> inserted the server side code here

 

harel