When working with reference fields, it is really important to understand how the display value for the reference field works. The display value for a reference field is what the end user actually sees when they search in a reference field to produce an autocomplete drop down and what they can see when a reference field gets populated. Information about reference fields and reference field display values can be found here.
Some questions about display values that I hear very often are “How do I show information from more than one field for the display value?” or “Can I have different display values on 2 reference fields that reference the same table?”. The limiting factor when answering these questions is that you’re limited to a single searchable display value per referenced table. What this means is that EVERY reference field that references a particular table needs to use that table’s display value so you cannot mix and match between reference fields. There are a couple of options that can be used to provide a bit more information to the user in these scenarios however.
The way I typically approach this type of requirement is to create a new calculated field that is a composite of the fields that I want to search on. Then I make that field my display value for that table. A good example of this is the ‘Name’ field on the user table. What you see is the full name of a user. If you look at the dictionary entry for that field however, you’ll see that it is actually a calculated field that pulls together the values from the First name, Last Name, and Middle Name fields.
Once this is done (and I’ve updated all of the records in the table so that my calculation gets stored on each record) I can make this field my display field for the table and change how searches are performed on references to that table. By using a ‘Contains’ type of search instead of the default ‘Starts with’ type of search against the display value for a table I can effectively search on multiple terms in the same field since I’ve included them in the same display value string. This article explains how to set up a ‘Contains’ autocomplete search for a particular table.
Customizing Autocomplete Search Behavior
Another useful option for reference fields is to display additional attributes in the autocomplete drop-down. These attributes aren’t searchable and they won’t show up as the display value when the field gets populated, but they do make it very simple to display more than just the display value in an autocomplete.
Good update on this, although it would be very helpful if there was a dynamic way to define this as a variable in the future. Either by an attribute, some type of property… Not sure the best underlining approach for this, but I know that we have rolled out very few application in the system so far and this functionality being configurable like this would of been great.
Matt
I agree. I know that this has been asked for before too. The best thing to do if you’d like to see this is to submit an enhancement request to the https://hi.service-now.com. The more people that ask for it, the more likely it is that it will be included as a feature in a future release.
Looks like the time has come!
Auto-complete for Reference Fields
This is an awesome improvement. I’ve contacted development about one drawback to the new solution currently. That is that you have to define the attributes for every single reference field that you want to use them on. What if you wanted to be able to do auto complete based on User Name or User ID? If you wanted this to be consistent across all reference fields you would have to update 260+ reference fields (which isn’t a good idea). I’ve contacted development with a proposal about this problem so we’ll see what comes. Just be aware that there are plusses and minuses to each solution currently.
Hi ,
Does this work on Variables in service catalog?
The ‘Contains/Calculated field’ method will, the other one won’t. Catalog variables don’t support the same attributes that regular reference fields do.
Hi,
Could you please provide me the link mentioned above, I am not able open the URL.
I have a requirement to have two reference field (User Table) on one form. One will display Employee ID and Other one will display User Name.
Regards,
Dubey
Just updated the link that was broken. I’m not sure that’s what you’re looking for though. I’ve never done 2 separate reference fields referring to the same piece of data. I think the best you could do in that case would be to have a second string field (or derived field) that would show the user name.