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

"data" is the variable for the getReference (or the requested_for sys_id in other words)...this is passed to the function myData.  So the function sets the values of those fields using the data from the sys_id it was passed.  So the requested_for's city, country_code, employee_number, etc...

 

If your "requested_for" field is referencing a custom table, your field names from the table may be u_ctiy, u_country_code, etc...So data.u_ctiy or data.u_country_code.


Please mark this response as correct and/or helpful if it assisted you with your question.
Steven

If city/zip/etc is not stored in the sys_user table, you need to create a Client Callable Script Include which does the lookup and retrieve the result using GlideAjax.

The Requested For Field is a reference field on sys_user?
Can you show us the table name + field names for the custom table and the fields names you want to retrieve?