How to check if a single record is indexed, and if not, how to index it


In this particular scenario, the user was not able to search against a specific user when creating a new HR Case either via the Platform or HR Agent Workspace. They wanted to know why.


The user's sys_user record was not properly indexed. Hence, it was not searchable.


After noting that this was only affecting one user, a check was made against the sys_user record to ensure that it was properly indexed. This was done via a sample script like the below:

// Test to see if the record is indexed - this should return some result if it is. Else, not.

var tsDebug = new GlideTSUtil();
var table = "_table_name_";
var doc = "_sys_id_of_record_";


Then, once it was found that the record was not properly indexed, something like the below sample script was run to index the single record properly:

// Index the targeted record

var table = "_table_name_";
var sysID = "_sys_id_of_record_";
new GlideTSUtil().indexDocument(table, sysID);

Running the above script in Scripts - Background resolved the issue, and the user was then searchable for the creation of HR Cases in both the Platform UI and HR Agent Workspace.

The above sample scripts should be tailored to each use case and tested thoroughly in a sub-Production instance before being used in a live Production environment.