how to query a table in client script in servicenow.

Community Alums
Not applicable

Based on requested for how to populate the values such as (city, country code, employee number, gender, street, zip code) from the custom table (u_uc_divya) to the service catalog.

 

PRITHVIRAMESH_1-1684429256943.pngPRITHVIRAMESH_2-1684429278028.png

 

 

16 REPLIES 16

Community Alums
Not applicable

yes, you're correct

@Community Alums 

 

quick question, your requested for referred to which table that custom one or sys_user?

Community Alums
Not applicable

custom table

 

@Community Alums 

 

If that field is reference field, the shared script should work

You just need to change the name of backend field value mentioned below, pls check the name of the fields and update in the script as below:

 

 

var data = g_form.getReference("requested_for",myData);

function myData(data){

g_form.setValue("city",data.city); // please check the "city" and data.u_city (backend name of field from table)

g_form.setValue("country_code",data.country_code);

g_form.setValue("employee_number",data.employee_number);

g_form.setValue("gender",data.gender);

g_form.setValue("street",data.street);

g_form.setValue("zip_code",data.zip_code);

}

 

Please check field names, this code should work

 

If my answer solved your issue, please mark my answer as Correct & Helpful based on the Impact.

 

Community Alums
Not applicable

in the above code what is the data referring to?