"Request again" button in Service Portal

Pablo Espinar1
Tera Contributor

Hello,

 

our customer have asked us to add a button in the Service Portal for "Request Again", which allows to duplicate the RITM with the same values in the variables and submit it. This could be useful when there are requests with many variables that are almost always the same and that have to be requested frequently.

Do you think is there any simple way to accomplish this?

 

Un saludo,
Pablo Espinar
ServiceNow Architect at NTT Data EMEAL

Please mark this response correct if I've answered your question. Thanks!
1 REPLY 1

Sandeep Rajput
Tera Patron
Tera Patron

This can be done in multiple ways, however the simplest possible way to do it via CartJS API. Using this API not only you can generate Request and Requested item via code but also add values to variables programmatically. For details refer to the URL https://davidmac.pro/posts/2022-10-10-sn-script-new-request/.

 

On your widget in the service portal, you will ask the user to input the requested item number which they need to duplicate. Simply use a GlideRecord query on the server side script of your widget and add a filter of requested item number chosen by the user.

 

 

var glideRITM = new GlideRecord('sc_req_item');
addQuery('number','RITM0010002') //let's assume chosen RITM is RITM0010002
query();
if(glideRITM.next()){
//Access the variables like following
var phoneModel = glideRITM.variables.phone_model; //Assuming there is a variable called phone_model


}

 

Once you get the glide record of RITM extract the variable values and populate them on a new request and requested item via the CartJS API.

 

Here is the reference of an article where the author has explained the usage of this API in detail.

Source: https://davidmac.pro/posts/2022-10-10-sn-script-new-request/