User Registration Request Auto Populate Company string to Company in User

mhafizam
Kilo Guru

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.

 

mhafizam_0-1748490243335.png

 

Appreciate any insights!

 

1 ACCEPTED SOLUTION

you can check the documentation here:

https://www.servicenow.com/docs/bundle/yokohama-customer-service-management/page/product/customer-se...

 

I hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.

View solution in original post

11 REPLIES 11

Rajesh Chopade1
Mega Sage

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

 

Hi,

 

Can you advise on this:

Create a Script Include to handle the fuzzy matching logic & call in your BR.

Ankur Bawiskar
Tera Patron
Tera Patron

@mhafizam 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

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!