In ServiceNow, reference fields are typically configured to use a display value, which by default is often the name or another identifier, such as a display name. If you want to search using the serial number instead, you'll need to adjust the way the reference field fetches and displays results. Here's how you can do that:
Step-by-Step Solution
-
Modify the Dictionary Entry:
- Navigate to the System Definition > Dictionary module.
- Find the dictionary entry for your reference field. The table name should typically be something related to where your asset field resides.
- Open the dictionary entry for the specific reference field.
- Look for the Reference Specification section. In this section, there will be a field called Reference auto-complete.
-
Configure the Reference Auto-Complete:
- Set up the Reference auto-complete by creating a dynamic filter option.
- You need to customize this filter by using a Script Include or business rule to modify the query for the autocomplete feature.
-
Script Include Configuration:
-
Associate the Script Include with the Reference Field:
- You would use an on-change client script or other similar mechanism to intercept the standard behavior and redirect the query to your custom search logic.
- It's important to know you'll need a custom script that fetches the data using your script include when the user types in the search box.
-
Test the Configuration:
- After implementing the changes, make sure to test the feature. Type in the serial numbers in the reference field to ensure the desired behavior occurs.
Alternative Method - Use Display Value
-
Change the Display Value of the Reference Field:
- Consider changing the display field of the
alm_hardware table to serial_number if it makes sense for your application.
- Navigate to the alm_hardware table definition and change the
Display field to the serial number field.
-
Scripted Filtering:
- Create a filter configuration using a query-based business rule or a GlideRecord query that specifies serial numbers.
- Use a reference qualifier that points to a dynamic filter for better control.
These methods give you a way to ensure that when users type the beginning of a serial number, they get a list of possible matches instead of based on the display name. However, depending on the intricacies of your instance setup, further tweaking might be necessary.
Notes:
- Be sure to test any changes in a sub-production instance or sandbox environment before deploying to production.
- Be mindful of performance impacts when altering reference fields, especially if you're writing custom server-side code.