- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2025 08:50 PM
Hi all,
I'm looking for some guidance on how to achieve the following in ServiceNow:
I've created a new string field called u_company_string on the User Registration Request table. When a user submits the form and enters their company name in this string field, I want the system to automatically populate the Company field on the corresponding user record in the sys_user record.
Ideally, it should not rely on an exact match. Instead, I’d like it to search and select the closest or most similar company name from the core_company table (e.g., fuzzy match or best match logic).
Has anyone implemented something similar or can recommend an approach? Any advice or examples would be much appreciated.
Appreciate any insights!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2025 11:37 PM
you can check the documentation here:
I hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2025 09:31 PM
Hi @mhafizam
You can achieve this by a Business Rule (after update & insert) on the User Registration Request table (u_user_registration_request or your custom table) to trigger when a record is inserted or updated and the u_company_string field is populated.
(function executeRule(current, previous) {
// Initialize the fuzzy match utility
var fuzzyMatch = new FuzzyMatchUtil(); // create script include and write your fuzzy logic there and call
var companyName = current.u_company_string;
if (companyName) {
// Find the best matching company
var companySysId = fuzzyMatch.findBestMatch(companyName); // pass company name & call function of your script include
if (companySysId) {
// Update the corresponding sys_user record
var userGr = new GlideRecord('sys_user');
if (userGr.get(current.user)) { // Assuming 'user' is the reference field to sys_user
userGr.company = companySysId;
userGr.update();
}
} else {
// Handle no match found (e.g., log a warning or notify admin)
gs.warn('No matching company found for: ' + companyName);
}
}
})(current, previous);
Create a Script Include to handle the fuzzy matching logic & call in your BR.
I hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.
thank you
Rajesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2025 10:56 PM
Hi,
Can you advise on this:
Create a Script Include to handle the fuzzy matching logic & call in your BR.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2025 10:47 PM
your users in sys_user should be onboarded via LDAP/AD
How are you handling that?
There has to have a fuzzy logic and what's that logic -> this you can discuss with your customer
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2025 11:07 PM
Hi,
Thanks for the response.
In this case, the user records are created locally in ServiceNow — we're not using LDAP/AD integration for onboarding.
As for the fuzzy logic, what I meant is something like this:
If a user enters “MBSB” or “Malaysia Building Society” in the u_company_string field, the system should automatically assign the company as Malaysia Building Society Berhad (which already exists in the core_company table).
So it's more of a best-match scenario where the input is matched to the most relevant company name already stored in the system.
Appreciate your input!