How to use RP .getParameterValue to fill a Reference field in a catalog item

Lisa Silvaroli
Tera Guru

I have a catalog item with 3 fields that should be pre-filled from the Call form  

 

Using the following in the "Default Value" of the variable I am able to get two "Single Line Text" fields to populate correctly

javascript: var answer = RP.getParameterValue("sysparm_sh_des"); answer;

 BUT it does not work for my Reference  type variables.  

 

This is the script I am attempting  to use as the default  value for the Reference field - I assume it should be "sysparm_company" since "company" is the name of the field on the Call form I am pulling from.  

javascript: var answer = RP.getParameterValue("sysparm_company"); answer;

Side note: I am modifying a Catalog Item that was created by someone else initially who has left. I am not familiar with the RP .   gerParameter scripts and I am not sure where to point the sysparm  value  

1 REPLY 1

Michael Ritchie
ServiceNow Employee
ServiceNow Employee

You can create an onLoad script and set the values.   See this article for instructions:


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



Edit: I found this article that has other examples on how to do it server side:


How To Get Parameters/Values From a URL in ServiceNow | SN Commander



Hopefully one of these options will work for you.   You could put the script in a script include and call that via the default value.