- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2016 06:06 AM
So I have a requirement to do a look up on a sys_user reference field on a Catalog Item using an underlying string field in the User record.
We have lookup on the User Name on that table for auto-complete and the documentation shows the ability to auto-complete with another reference field on User, but not with a string field. Auto-Complete for Reference Fields - ServiceNow Wiki
Anyone have a clue how to make this work for a string field?
Thanks!
Cal
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2016 06:14 AM
Cal! Its been a while, I hope you are doing well and enjoying this wonderful hot weather in NC!
I have set this up for several customers who say want to filter users based on their employee id number or location based off a location code. Here are some instructions I put together that I shared internally may help you:
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!
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:
i. ref_ac_columns_search=true,ref_auto_completer=AJAXTableCompleter,ref_ac_columns=first_name;last_name;employee_number
ii. 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.
iii. 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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2016 07:38 AM
Hey Michael,
I can get this to work awesomely on INC when I put the attribute right on the field, but this is a Catalog Item Variable field and there is no Attribute to be set. I tried from the user table and can get it to show in the search, but it will not do the look up in the Catalog Item or other tables, like sc_task.
Auto-Complete for Reference Fields - ServiceNow Wiki following your code and this, I added this string to the attributes on sys_user.
iterativeDelete=true,ref_ac_columns_search=true,ref_auto_completer=AJAXTableCompleter,hasLabels=true,ref_ac_columns=email; u_oracle_id,ref_ac_order_by=name,display_image=photo
Thanks!
Cal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2016 07:43 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2016 08:48 AM
Cal,
Assuming you have a variable of type reference, there are attributes, but hidden on the Default Value tab for whatever reason. The field label is "Variable Attributes". I have used the above code on variables with success in the past so it should work.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2016 08:53 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-21-2016 09:03 AM
Chuck and michael.ritchie ,
Thanks! I was so close before I stepped away to a mtg. I was looking that field and looking at Jim's code you sent and putting 2+2=5 together.
Have a great day!
Cal