Create Incident from requested item

amaneet
Kilo Contributor

Hi Folks,

We have a requirement to create an incident from requested item. Our approach is to give a UI action on sc_req_item_table and then create an incident via a record producer.

We are facing a trouble to pass the parameters via url to client script. We will use this parameters in on load client script and then play around with that value.

Have gone through the following link, but nav.do is playing spoilsport.

https://www.servicenowguru.com/scripting/client-scripts-scripting/parse-url-parameters-client-script...

Any ideas please?

10 REPLIES 10

Deepak Ingale1
Mega Sage

3 Ways to Populate Values in ServiceNow via the URL



This is what I refer to whenever I require to pass information using parameters.


I am using option 2 of that, but the null value is passed in parameter.


Hi Amaneet,



Could you please share code of your UI action and onLoad catalog client script?


Hi Deepak,



here is the code:



UI action



current.update();


var url='com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=ce3c5fbddb3f030055d7712ebf9619cc&ritm='+current.sys_id;


action.setRedirectURL(url);



Catalog client script



function onLoad() {


    //Type appropriate comment here, and begin script below


   



var IDval = getParmVal('ritm');


g_form.addInfoMessage(IDval);



g_form.setValue('short_description',IDval);




function getParmVal(name){


      var url = document.URL.parseQuery();


      if(url[name]){


              return decodeURI(url[name]);


      }


      else{


              return;


      }


}


}