how to query a table in client script in servicenow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2023 10:02 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2023 10:45 PM
yes, you're correct
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2023 10:50 PM
@Community Alums
quick question, your requested for referred to which table that custom one or sys_user?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2023 10:56 PM
custom table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2023 11:00 PM
@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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2023 11:48 AM
in the above code what is the data referring to?