How to change display value of Reference variable in Service Portal?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2019 11:36 PM
Hi,
I went through many questions on this site but could not find any solution for this.
How can I change the display value of Reference variable in Service Portal?
using following attributes: ref_auto_completer=AJAXTableCompleter,ref_ac_columns=code,ref_ac_columns_search=true,ref_ac_display_value=false
I only managed to display "code" in the selectbox options and I can search for the "code", however the display value is still "A RSC L22" -> I want this to be "1410000297"
Note please that I do not want to change display value in Cost Center table.
Also using Lookup Selectbox seems to be not possible, because it's always showing all Cost centers (~15.000 records) and causing performance issues.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2019 12:04 AM
Hi Peter,
Unless in the dictionary that column is made display as true and the other as display = false this won't happen. the changes for display = true for a column are global and will impact wherever any field is referencing this table using lookup field
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2022 03:23 AM
Hi Peter,
a bit late here but maybe this helps someone with a similar problem.
What you could do is have an onChange Script on your cost_center variable and manipulate this displayed value with g_form.setValue("cost_center", newValue, [your display Value])
The setValue() function has a third parameter(at least when used on a reference field) which allows you to set a display value which is not the one defined on the table.
Maybe something like this:
function onChange(control, oldValue, newValue, isLoading) {
if ( newValue == '') {
return;
}
g_form.getReference("cost_center", callback);
function callback(cost_center_record){
g_form.setValue("cost_center", cost_center_record.sys_id, cost_center_record.code);
}
}
So your cost center sys_id is still stored and usable in flow/workflow etc. but on the catalog form view the "code" field value is displayed.
Kind regards
Kevin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2024 10:14 AM