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

Alikutty A
Tera Sage

Hi Jon,



You can update the attributes field in the dictionary of your reference field to perform an auto complete search on lookup.



Add this in the attributes



ref_auto_completer=AJAXTableCompleter,ref_ac_columns_search=true,ref_ac_columns=last_name;first_name;user_name;email,ref_ac_order_by=name,ref_ac_display_value=false



The field would be searched against the highlighted columns on your table (last_name;first_name;user_name;email)



Thanks


Please Hit like, Helpful or Correct depending on the impact of the response


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


Would this approach also translate to the service portal view in addition to the view in the main instance?


Yes shows up a little differently.   I have first name, last name, email and location



Platform UI:


find_real_file.png



Service Portal:


find_real_file.png



Please mark any of these posts helpful or the correct answer to your question.