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

I tried this code and it is not working. I am on Jakarta. Is there anything else I need to update other than client and server script?


Hello, It's work in Helsenki, but I having upgrading my dev plateform in Jakarta ; & some form are redirect in RITM, but 2 form are not redirect & frozen to "Submit..."


Thanks a lot Jason


Hi Jason, I'm looking to do the same thing...redirect user to the new RITM after catalog item submit (we are not using the cart, so each REQ has only 1 RITM).  

I'm using your scripts that you posted but it's not working...should I be able to copy and paste the full scripts you posted for server and client script?  I'm on London.  thanks!

sowmyaprabhakar
Tera Contributor

Hi, 

 

we have a similar requirement, to redirect the create incident record producer to ticket form page, post submission. 

In this case, I am successfully able to redirect, to ticket form page, but unable to fetch the sys id.

 

$scope.triggerOnSubmit = function(item_sys_id){

                        $scope.data.sc_cat_item.item_action = "order";

                        $scope.data.sc_cat_item.quantity = c.quantity;

                        $scope.data.id=item_sys_id;

                        //alert($scope.data.id);

                        if (g_form){

                                    g_form.submit();

                                    $window.location = "https://sadaradev.service-now.com/sp?id=ticket&table=incident&sys_id=" +$scope.data.id;

                                    get();

                        }

            }

            function get(){

                        spUtil.update($scope);

            }

 

  In this case, $scope.data.id is not fetching the sys_id of the current incident. Hence, in this case,i am unable to redirect to the exact page.