Dynamically change Glide List option labels/display values in Client-Side code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2023 01:12 PM
I created a Glide List field whose reference table is the Story table [rm_story]. Think Agile Development. The Glide List field, however, is on the Defect table [rm_defect]. On the Task table [task], the Number field is the Display Value. However, on the Story table, a Dictionary Override record is in place which sets the Short Description field as the Display Value.
Now that you have that background information, here's my objective:
On the Glide List field, for each item, the option value is the Sys Id and the display value/label is the Short Description. Preferably just for this Glide List field alone, I want the display value/label to be the Number field.
That means reversing the Dictionary Override on the Story table is out-of-the-question since you can only have Display Value per table. That'd be an easy fix. This is a bit more challenging than that. My idea was create a client-side script or UI Policy script which, on load, grabs the Glide List Field, loops through all the options, perform a lookup of the Number field value for each Sys Id, and then replace the option label. To do so, I may have to enable DOM manipulation. I'm not sure ServiceNow APIs like g_form offer the ability to update the display values of a Glide List field in the fashion in which I'm speaking.
If there's another way or several others ways to attack this one, I'm all ears. If the solution affects all Glide List fields referencing the Story table, that's acceptable. But what I'm not looking to do is change the Display Value for the Story table. That stays as Short Description. If anything, it'd be more helpful if the Glide List option labels/display values showed Number + Short Description, but just Number would sufficiently satisfy the objective.
Thank you!