populating reference field list when another field changes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2024 08:46 PM
I am trying to populate a reference field values when another field changes. I have script include and calling it from catalog client script but doesnt seem to be working. When I print it is getting the right values but not setting the reference list.
I am using the following,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2024 09:06 PM
Hi @samadam ,
If answer1 have sysid then your script should work and if you are returning name from script include then use.
g_form.setDisplayValue('office', answer1);
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2024 09:08 PM
I am returning array of sys_ids and want to populate the list not set one value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2024 09:19 PM
Hi @samadam ,
Use below script to populate the value.
var answer1= [
'ee826bf03710200044e0bfc8bcbe5de6', // Replace with actual sys_id of the user
'0e826bf03710200044e0bfc8bcbe5d7c'
];
// Convert the array into a comma-separated string
var watchListValue = answer1.join(',');
// Set the value of the watch_list field
g_form.setValue('office', watchListValue);
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2024 06:14 AM
sysids are already returning as comma separated.