- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2024 11:44 AM
I am trying to get the list of values for a reference field to display in alphabetical order and for each value to display on a new line. Attached is how it currently looks, below is how I would like it to look:
Supporting Analyst
Abel Tuter,
Tamara Declue,
User 1,
Zane Sulikowski
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2024 12:45 PM
There are not any settings or configuration change options for list fields, but you could run a script like this to re-order the values - I haven't found anything to put each one on a separate line:
var arr=[];
var lst = new GlideRecord('sys_user');
lst.addQuery('sys_id', 'IN', current.u_list); //list field name
lst.orderBy('name');
lst.query();
while (lst.next()) {
arr.push(lst.sys_id.toString());
}
current.u_list = arr.join(',');
This would be in a Business Rule before insert and update on the incident table when the list field changes.
You could also run this as a Fix Script to modify all of the existing records - excluding or using a different addQuery, and changing the last line to a setValue and adding a lst.update();
If you really need to see it on the form each time a user is added or removed, you could put something like this in a Script Include and call it with a GlideAjax onChange of the field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2024 12:13 PM
Is it possible for this field to be populated when the form/record is loaded, so you want to see this then, and/or could the Supporting Analyst field be changed while the record is displayed, so the solution would have to work onChange of this field? Where are you viewing these records - native UI, Service Portal, workspace,...?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2024 12:27 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2024 12:45 PM
There are not any settings or configuration change options for list fields, but you could run a script like this to re-order the values - I haven't found anything to put each one on a separate line:
var arr=[];
var lst = new GlideRecord('sys_user');
lst.addQuery('sys_id', 'IN', current.u_list); //list field name
lst.orderBy('name');
lst.query();
while (lst.next()) {
arr.push(lst.sys_id.toString());
}
current.u_list = arr.join(',');
This would be in a Business Rule before insert and update on the incident table when the list field changes.
You could also run this as a Fix Script to modify all of the existing records - excluding or using a different addQuery, and changing the last line to a setValue and adding a lst.update();
If you really need to see it on the form each time a user is added or removed, you could put something like this in a Script Include and call it with a GlideAjax onChange of the field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2024 12:25 PM - edited ‎08-13-2024 12:28 PM
***Accidental reply***