Service Portal - Redirect to RITM

ProbirDas
Tera Expert

Hello Community,

I am trying to modify the out of box "SC Catalog Item" widget which displays the request/incident number using spUtil.addInfoMessage() after submission of the item. Instead of just displaying the number, I want it to redirect to the specific record. For incident, it works fine. For request, I want to redirect the user to the RITM record instead of the REQ record. I believe I need to fetch the RITM sys_id from the server script for this.

See the code below. How do I access the sys_id and number of the RITM within the client controller?

In client controller:

//req_id holds the sys_id of the REQ

$scope.server.get({request_id:req_id}).then(function(r){

        //how do I access the sys_id and number of the RITM here?

        //$scope.data doesn't have these parameter

        //how do I make use of 'r' to access those values set in the server script? I checked JSON stringifying of 'r'. It didn't help.

        //Checked the value of r.data.ritm_id / r.data.ritm_number, it returns undefined

});

In server script:

if(input){

        if(input.request_id){

                  // Debugging gives me the correct value of sys_id of the REQ

                  var gr = new GlideRecord('sc_req_item');

                  gr.addQuery('request',input.request_id);

                  gr.query();

                  if(gr.next()){

                            data.ritm_id = gr.sys_id;

                            data.ritm_number = gr.number;

                  }

        }

}

else {

// other scripts

}

Thanks,

Probir

1 ACCEPTED SOLUTION

ProbirDas
Tera Expert

I was able to fix it. Had to convert the values to string.



In server script:


if(input){


      if(input.request_id){


                  // Debugging gives me the correct value of sys_id of the REQ


                  var gr = new GlideRecord('sc_req_item');


                  gr.addQuery('request',input.request_id);


                  gr.query();


                  if(gr.next()){


                        data.ritm_id = gr.sys_id.toString();


                          data.ritm_number = gr.number.toString();


                  }


      }


}


else {


// other scripts


}


View solution in original post

14 REPLIES 14

ProbirDas
Tera Expert

I was able to fix it. Had to convert the values to string.



In server script:


if(input){


      if(input.request_id){


                  // Debugging gives me the correct value of sys_id of the REQ


                  var gr = new GlideRecord('sc_req_item');


                  gr.addQuery('request',input.request_id);


                  gr.query();


                  if(gr.next()){


                        data.ritm_id = gr.sys_id.toString();


                          data.ritm_number = gr.number.toString();


                  }


      }


}


else {


// other scripts


}


Hello,



I am also trying to implement similar configurations in my instance, but no luck. If you don't mind, can you please share the updated code.



Thanks in advance.



Regards,


Jai


Can you send me the script that redirects to the incident record.


Ont the Service Portal homepage I created a incident widget. It shows the incident number and short description but when I click on that it shows 404 error instead of showing the record.


Not sure where do I change script in HTML and client controller. I cloned My requests Widget and made some changes


I am using the window.location global to redirect to the resultant url



#table - either RITM or INC (can be any other table set as target in record producer)


#sys_id - sys_id of the record


#these are part of the issueMessage function



var url = "?id=ticket&table="+table+"&sys_id="+sys_id+"&view=sp";


$window.location = url;