Select the column in the reference type variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello community, I have a reference variable that by default shows the "Name" column, but I need the "u_managed_by" column to be visible only in this case. I applied this script
But the display ended up like this:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @jkelvynsant
Share the script that you’ve applied for a more assertive answer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Use a Formatter / Auto-populate field:
Instead of trying to change the reference display:
Keep reference variable normal (shows Name)
Add another variable (read-only)
Populate it with u_managed_by
Example Catalog Client Script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || !newValue) return;
var ga = new GlideAjax('GetManagedBy');
ga.addParam('sysparm_name', 'getValue');
ga.addParam('sysparm_sys_id', newValue);
ga.getXMLAnswer(function(response) {
g_form.setValue('u_managed_by_display', response);
});
}
Script Include:
var GetManagedBy = Class.create();
GetManagedBy.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getValue: function() {
var gr = new GlideRecord('your_table');
if (gr.get(this.getParameter('sysparm_sys_id'))) {
return gr.u_managed_by.toString();
}
}
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
By default whichever field is marked as Display=true on that table will be shown once you select the reference value
If you wish to change it to some other field then it would be a global impact so wherever this table is being referred it will start showing Managed by instead of Name
Note: please discuss this with your customer
OR
Another approach is to use Lookup select box variable and point to that table
In Lookup label field give -> u_managed_by
Example like this:
Output
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
