how to buid a URL for prefilling a field value for one record producer?

Raju Singh1
Tera Expert

how to buid a URL for prefilling a field value for one record producer.

I have one variable called 'user name' in record producer.

I have a URL for that record producer. As per my requirement whenever a new user is created in the system, it sends a notification which contains a URL to that record producer. Now when I click on this URL it should prepopulate a variable called user name with the a new user created.

Could you please help me achieving this requirement.

1 ACCEPTED SOLUTION

Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

Well, you need to put in a parameter in the url to have the sys_id of the user.. like this, here I added sysparm_caller



https://devXXXXX.service-now.com/com.glideapp.servicecatalog_cat_item_view.do?v=1&sysparm_id=66c313e...



Then you need a onLoad Catalog client script that puts that info into the variable.. in this case I'm putting it into a variable called "caller_id"



find_real_file.png


View solution in original post

11 REPLIES 11

Reference field actually mattered.. I didn't make it a reference field...



So, now I was able to populate a value with the help of a reference field when analyzing the whole process again. Only with the help of client script I was able to achieve this.



However, I have a second field value called 'location' which I am trying to populate for the same user. The location field is not a reference field. its a string.



I have tried both onLoad script and change script but the location field is not populating. Here is my code.



function onLoad() {


    //Type appropriate comment here, and begin script below


    alert("abc");


var userobject = g_form.getReference('u_name');


g_form.setValue('location',userobject.u_locations);


alert(userobject.u_locations);


}



//Here u_name is the input value for the user id from the sys_user table







I also tried this for onChange



function onChange(control, oldValue, newValue, isLoading) {
//   if (isLoading || newValue == '') {
//         return;
  // }


    //Type appropriate comment here, and begin script below
alert("abc");
userobject = g_form.getReference('u_name');
g_form.setValue('location','userobject.u_locations');
alert('userobject.u_locations');

   
}


Raju Singh1
Tera Expert

find_real_file.png