Reference - Display another field than the default display field

sylvain_hauser
Tera Contributor

Hi,
Is there a way to display in a reference field something else than the default display field for a specific variable?

I explained why.
On the CMDB, the display field is the code of the CI, in order to allow IT people to quickly find the right CI in any form.
But in the Service Catalog, there are some collection lists to select for example all the softwares you want: but the "classic" end user don't know the code, and don't want to check one by one the button of the screen

i asked exactly the same question for a list collector, and I know it is not possible, but if it exists for a simple reference field, it will save me.

Thanks
PS: I don't want to change it in general like it is proposed here:
http://wiki.service-now.com/index.php?title=Changing_a_Reference_Field%27s_Display_Value

4 REPLIES 4

Mark Stanger
Giga Sage

There's not a way to do this currently.


sylvain_hauser
Tera Contributor

Hum, so what do you think is the best to not only display the Code?
I am thinking about have another variable next to it, read only, that will look for the other field I want to show for this variable... But I am wondering what will be the best to proceed in order to not have an impact on the performances.

Is there way to do it without having to use a business rule like this one:
Service Catalog Variable To Get Group Members


The only thing you can do really is to set up the reference field display value so that it contains information that makes sense to everyone. Typically I handle this type of thing by creating a new field and then calculating the value in it. You can see a good example of a calculated field by looking at the dictionary entry for the 'Name' field on the 'sys_user' table. 'Name' is actually a calculation of First and Last name. You could then set up this new field to be the display field for its table.

When you do something like this, it often makes sense to change the autocomplete search behavior for that table to use a 'contains' search instead of a 'starts with' search.
http://wiki.service-now.com/index.php?title=Customizing_Autocomplete_Search_Behavior

Also, calculated fields will display a calculated value immediately for all of the records in the table, but the calculated value is not actually stored until each record has been updated. This means that if you want to be able to search on the new calculated value you need to update all of the records in the table that the calculation exists on.


sylvain_hauser
Tera Contributor

Because in this case we couldn't change the default display value for all only because of the service catalog, I did the following workaround:

- create a new catalog variable, read only
- create the following catalog client script

SCRIPT
On change Location variable:

function onChange(control, oldValue, newValue, isLoading) {

if (!newValue || newValue == '') { //If the source is empty
g_form.setDisplay('location_display', false); //Do not display the name (hide)
return; //Stop
}

var source = newValue; //Get the sys id of the source
var gr = new GlideRecord('cmn_location'); //Table of the source
gr.get(source); //Get the single record
g_form.setValue('location_display',gr.full_name); // Display the full name instead of the display value
g_form.setReadonly('location_display',true); // Set the field read only, even for admin
g_form.setDisplay('location_display', true); // Display the field with the full name already filled in
}