The CreatorCon Call for Content is officially open! Get started here.

List attributes beyond name for user reference fields

jonathanstewart
Tera Contributor

Looking for a way to display additional information about a user record in a lookup beyond the name of the user.  I have many users that have the same name but other distinguishing characteristics that would help users make the correct selection.

1 ACCEPTED SOLUTION

Michael Ritchie
ServiceNow Employee
ServiceNow Employee

Yes this is definitely possible.   Here are some instructions I had put together for some peers of mine.   This use case was to use employee ID as a search criteria, but you don't have to do that.  




Use Case: I would like to search for callers by several attributes and not just by their name.   OOB the user can click the magnifying glass beside the reference field and search that way, but it requires extra clicks and time.   Fortunately ServiceNow can display other data on the Type Ahead popup and that data is also searchable!


find_real_file.png



Notice above I am not only showing the employee's name, but also the first and last name as well as the employee number of that user.


·                 You can also set it up where you search all the columns you are displaying.   This comes in handy if the users want to be able to search on first name, last name, or employee ID all in the same field.   Also notice above, I typed in "111" and it searched both the employee ID column and presented several results where the employee number starts with "111".   I could have also typed in "smi" to get the same results.


·                 This especially comes in handy with locations and wanting to search for a city or state or location code/number.



This is also very easy to configure with the steps below:


  • Now I mentioned above to make sure the "number" field is a string value, the reason I mentioned this is because if you want to allow searching in all columns it must be a string type column.   Numbers, email, etc aren't searchable.
  • To set this up, you personalize the dictionary on the particular field — this is done on a field by field basis so you may need to do this multiple times.   So for example, to make the above work for the incident caller, right click on the Caller label and choose Personalize Dictionary.   Then:
    • Make sure you are on the Advanced View — under Related Links you may see "Advanced view" so click that if it shows up.
    • On the Advanced view you will see a field called Attributes.   OOB the value of this field is: ref_contributions=user_show_incidents
    • You will need to add a few new attributes which are always separated by commas, then paste in the following:
    • ref_ac_columns_search=true,ref_auto_completer=AJAXTableCompleter,ref_ac_columns=first_name;last_name;employee_number
      • Here is an explanation on what these mean:
        • ref_contributions=user_show_incidents — this shows the UI Macro that shows all the caller's incidents
        • ref_ac_columns_search=true,ref_auto_completer=AJAXTableCompleter — these allow the searching to happen
        • ref_ac_columns=first_name;last_name;employee_number — this is how you set what additional columns appear.   In this example I am showing the first and last name and employee number.   You must enter the database column name, not the label.   You can certainly add additional ones by separating them with a semicolon.
  • The end result Attributes value will be:
  • ref_contributions=user_show_incidents,ref_ac_columns_search=true,ref_auto_completer=AJAXTableCompleter,ref_ac_columns=first_name;last_name;employee_number


View solution in original post

40 REPLIES 40

Good day to you Michael. Thank you for responding.

I didn't think so, but I wanted to just double check to see if it was even remotely possible.

 

Much appreciated.

Hi Michael Ritchie,

 I had same type of requirement, but data is not showing up even after using use ref_contributions=user_show_incidents,ref_ac_columns_search=true,ref_auto_completer=AJAXTableCompleter,ref_ac_columns=first_name;last_name;employee_number.

Reason

--------------------------

1. User doesn't have any role. Data will be be accessed only who is having some role

We had an ACL where data will be visible only who is having some role. Can we open few fields who is not having role as well..

 

find_real_file.png

 

 

edwajs
ServiceNow Employee
ServiceNow Employee

You can specify the attributes on a field by field basis, as has been shown.   You can also put the attributes on the sys_dictionary record for sys_user.collection to make them a default for the table.   The individual field attributes/catalog variable attributes would override these table-specific settings.



You should also be aware that if you put a reference decorator on some of these fields, it can alter or suppress the behavior of these reference attributes, depending on the release.



Because the Service Portal is a different UI and is intended to be device-agnostic, it may behave or present information differently.


I was not able to find what you are referencing at the dictionary level.  


Here is a screenshot of the sys_user record, no field, type is collection.  


Screen Shot 2017-03-14 at 2.47.26 PM.png



This is the master sys_dictionary record for the sys_user table.   It shows the default attributes for sys_user, including the reference completer attributes which are the defaults for reference fields to the sys_user table.   This includes glidelist data type fields, and it should also apply by default to catalog reference variables and list collector variables.



There was a bug back in Berlin where these collection attributes did not apply to catalog variables, but I think that was corrected several years ago.