HR Case Creation Search
Terms used
Case Creation - The page that the "Create New Case" module directs to for creation of HR Cases by agents.
Case Creation Configuration - This is the record used to configure parts of the Case Creation page.
Case Creation Service Configuration - This is a record that allows some configuration for what fields show for a service on the Case Creation page.
Text Indexing | Regenerating text Indexes - Text indexing allows users to search for string values from records via text search.
Zing / Text search - This is the underlying keyword search that the Case Creation page uses.
How search works
Search on the Case Creation page uses Zing / Text search which has the benefit of being able to search across all indexed fields on a table. For example, instead of just searching for users by name, text search allows searching for users by employee number, department, or email. Any field on a table can be searched if it is indexed, but it must also be on the table itself (dot walking is not supported) and readable by the user searching.
The Case Creation page supports searching three tables (and their extensions) by default: User [sys_user], HR Profile [sn_hr_core_profile], and HR Case [sn_hr_core_case]. Most searches will use the User and HR Profile tables. Users can be searched by any indexed fields, such as Name, Department, or Email. The User table will be searched first, and if no results are found then the HR Profile table will be searched. This ordering is set in the hr_CaseCreation script include variable "this.searchTables". If the "Force partial search" field on the Case Creation Configuration record is set to true, then the search term can be a partial match to an indexed field value, e.g., searching "John" and seeing results for "Johnie". If this field is false, then only users exactly matching the search term will be returned.
Searching the HR Case table is only done if a case number is searched, e.g., HRC0000101. This case search will return all users in user fields on the table listed in the Case Creation Configuration field "Task user fields" which is Subject person, Opened for, Opened by, and Watch list by default. The search can also be narrowed further to a specific user by adding their displayed name to the search.
Debugging search
Incorrect/No results found - This issue can be caused by various problems. First check to ensure the table and fields searched are indexed. Navigating to a record list for sys_user or sn_hr_core_profile can quickly show if the table is text searchable by checking if you can search "for text".
If "for text" is not shown, then the table is not text indexed. If "for text" is shown, but no search results are found for a search then there is an issue with the text indexing for the field being searched or the field is not readable.
If searching in the record list returns different results than on the Case Creation page, this might indicate that the issue lies with the "Force partial search" option on the Case Creation Configuration record. To test this, try adding an asterisk (*) to the search term (e.g., John*) on the record list. If no results are returned after adding an asterisk, the search term might be "ambiguous" and this is why the Case Creation search returns no results. Workarounds for this issue could be to use more or different search terms to search for the user (e.g., full name, employee number, email, etc.), to turn off "Force partial search" in the Case Creation Configuration record, or to revise text search properties such as "glide.ts.max_wildcard_expansion" (NOTE: this will affect more than just the Case Creation search).
Error messages on page or console - These can be the result of a scripting error in the rest call, script include, or elsewhere, and may require individually testing various components of the search API. Debugging could start with determining which rest call is failing and investigating the hr_CaseCreation script include for possible issues.
Configuring search
Some components of the Case Creation search can be configured from the Case Creation Configuration [sn_hr_core_config_case_creation] record available under HR Administration -> Case Creation Configuration. The documentation link above generally covers the fields and their descriptions.
Page size - Determines how many records will be queried at a time, similar to how a record list will show "1 to 10 records of 100" or similar. This is 10 by default, and scrolling down through the search results will load more records automatically.
Minimum input length - This sets the minimum number of characters that must be entered to return results.
Limit users on search / User search condition - Limit the searchable user records by a condition (e.g., Active is true).
Additional display fields - Show additional information about the users searched (e.g., Department, User ID, Location).
Links - Show links created in Link Generator next to the selected user's name.
Advanced configuration
Changing table search order
In the hr_CaseCreation script include, the "this.searchTables" variable could be modified to reorder or change what tables are searched. The tables listed must be a sys_user or extension table, or have a valid reference to a sys_user.
this.searchTables = ["sys_user", "sn_hr_core_profile"];
Additional display fields on reference search:
In the hr_CaseCreation script include, an "attributes" property could be added to the fieldObject in addReferenceProperties to show some extra information for each record.
if (['opened_for', 'subject_person', 'assigned_to'].indexOf(fieldObject.column_name > -1)
fieldObject.attributes = "ref_ac_columns=employee_number,ref_ac_columns_search=true,ref_auto_completer=AJAXTableCompleter";
-- OR --
If multiple additional display columns are needed, a property containing a csv string of the columns could be added to the fieldObject
fieldObject.additionalDisplayColumns = "email,employee_number";
and used in the case_creation ui page's sn-reference-picker by adding a new attribute
additional-display-columns="\{{field.additionalDisplayColumns\}}" (NOTE: Remove \'s)
NOTE: Only fields defined in the sys_ui_list "Mobile" view for the referenced table are available for ref_ac_columns/additional-display-columns on the case_creation page (limitation of the sn-reference-picker directive used by the case_creation ui page). If a field is not showing, then it may need to be added to the sys_ui_list record for that table.
Additional search fields on reference search
In the hr_CaseCreation script include, the "searchField" property could be modified in the fieldObject in the addReferenceProperties method to allow searching additional fields (default is to search the display field only). The "searchField" property takes a string of ";" separated field names as a value (e.g., fieldObject.searchField = "field_1;field_2;field_3").
fieldObject.searchField = eleRecord.getDisplayName(); // This is the current code
if (['opened_for', 'subject_person', 'assigned_to'].indexOf(fieldObject.column_name > -1))
fieldObject.searchField += ";email;employee_number";
These fields do not need to be shown as additional display columns to work.
https://www.servicenow.com/community/hrsd-articles/hr-case-creation-search/ta-p/2309894