How to add caller.user_name to global text search

Morten Steenbac
Giga Expert

I would like to be able to write a User ID in global text search, and see all incidents where the user id is 'caller' or 'assigned_to'.

How to achieve that?

I tried adding the attribute: ref_auto_completer=AJAXTableCompleter,ref_ac_columns=user_name,ref_ac_columns_search=true,ref_ac_display_value=false

...on caller_id - as described here: Re: Using the User_Name (user id field) as the search qualifer on Incident Management. , but it didn't seem to work.

1 ACCEPTED SOLUTION

Morten Steenbac
Giga Expert

The following solution was proposed by HI support:



The solution you need will be to add data into an indexed column on Incident that includes the user ID. You have two fields you want to search for a user ID - Caller and Assigned To - so I suggest generating two new columns, which store the user ID for the respective field. These columns will need to be populated from the Caller and Assigned To fields, to do a lookup based on the user name to extract the user ID. You may need to use a Client Script to apply this on new records, and another script will also be needed to populate existing records. By then adding a text index to these two new columns - lets calls them u_caller_userid and u_assigned_to_userid - then you will be able to use these in a global text search. Once these user IDs are found in the search, the index will be returned.



https://docs.servicenow.com/bundle/helsinki-servicenow-platform/page/administer/search-administratio...



You probably won't want these new fields appearing on the form, but you will need to add them to the form so that the Client Script can update them on saving of a record. However, you can hide them using a UI Policy.


As you can see, there is not really an OOTB method for what you need, but you can use existing functionality to extend the capabilities of the application.


View solution in original post

13 REPLIES 13

Mahira
Tera Guru

Hi Morte,


I see this functionality you looking for is already available Out of the Box.


For example, I searched for beth.anglin and it has listed me all incidents where she is an assignee or caller.


Is this what you are referring to or is there something else?





search.png


Beth Anglien's user id is beth.anglin - that is what I would like to search for.


Yes that's what I had typed in the search box.


If you can share the screenshot of your text search group , I can take a look


Yes you are right - in my test instance I can search for beth.anglin and get related incidents.


How ever - if I search for my own username admin_msj, I don't get any hits although I have several incidents assigned to me.


Does the user need to have some group membership or role to appear in global text searches?



And by the way - I tried changing beth.anglin's username to 'abc' - and then you can still get hits searching for beth.anglin. So probably its just returning hits because here username consists of here firname.lastname.


And you don't get any hit's searching for 'abc'.


Hi Morte,



The new value abc doesnot return any results because of this :



A table is not automatically reindexed when data on a referenced table changes. For example, if a record in the knowledge base references a group and the group name changes, searches for the old group name will still yield results and searches for the new group name will not.



One other area you can take a look at is setting the ts_weight attribute or generating text index. I would take extra caution before generating text index on a production environment.



Regards,


Mahira