Why getDisplayValue() displaying sys_id instead of value for glide list type field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 09:37 PM
Hi Community,
I have a glide list type field and I want to copy display value of that field to another field of string type.
I created a before- insert/update Business rule for the same with below code:
current.field1=current.field2.getDisplayValue();
gs.addInfoMessage(current.field1);
The above info message is displaying sys id instead of value.
Please someone help on this.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-01-2025 11:49 PM
@Ankur Bawiskar I already did it but still not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-02-2025 12:29 AM
very difficult to troubleshoot without having the instance details.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 11:20 PM
Hello
Please share a screenshot of your dictionary with filter Display = true.
you're working with a reference field where the "display" field on the referenced table hasn't been properly configured and hence you are getting sysId's.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 09:49 PM
Hello @Ankita Kolhe,
If getDisplayValue() is returning the sys_id instead of the display value in your Business Rule, it's likely because you're calling it on a field that is a reference field and the field value is not fully populated at the time the Business Rule is executing.
This is one of those common issues in before Business Rules where the reference field may not have been fully resolved yet.
To resolve this, I'd request you to try using the getDisplayValue() method with an after Business Rule, that should resolve the issue.
Else if you want to explicitly use before business rule, then you can load the referenced record first and then get the display value:
// Before Business Rule Example
var category = current.category; // Assume category is a reference field
if (category) {
var categoryRecord = new GlideRecord('sc_category');
if (categoryRecord.get(category)) {
var categoryDisplay = categoryRecord.getDisplayValue('name'); // 'name' is the display field
gs.info('Category: ' + categoryDisplay);
}
}
I hope this helps. If it helped resolving your issue, please mark it as helpful
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2024 10:54 PM
Hi @Ankita Kolhe ,
(function executeRule(current, previous) {
var userList = current.field2.split(',');
var displayValues = [];
for (var i = 0; i < userList.length; i++) {
var user = new GlideRecord('sys_user');// you have to replace the table with your glide_list field referring to
user.addQuery('sys_id', userList[i]);
user.query();
if (user.next()) {
displayValues.push(user.getDisplayValue());
}
}
current.field1 = displayValues.join(', ');
})(current, previous);
If my response helped, please mark it as the accepted solution ✅ and give a thumbs up👍.
Thanks,
Anand