Caller field and sys_user list do not match up

adamabel
Tera Contributor

When looking at an incident caller field, I expect this to match the sys_user list I have but it does not.  I found that the company name field dictated this, by finding a user without a company name and updating it to one in that table, and then it would show up in the caller field.  I ran a script to update all users that have a blank company name or null and update it to the ID of a company name we have in our system and it did.  Unforunately I'm still not seeing the same number of users in the caller search field vs the sys_user.list as expected.  I got a few more to show up but thats it. Can anyone tell me how to find what other depenencies this search field would have so I can update those records?

 

 

(function() {
    // Create a GlideRecord object for the sys_user table.
    var gr = new GlideRecord('sys_user');
    
    // Query records where the company field is empty or null.
    // Use addNullQuery to catch null values.
    gr.addNullQuery('company');
    // Also check for empty strings if necessary.
    gr.addQuery('company', '');
    gr.query();

    // Log the number of records found.
    gs.info('Found ' + gr.getRowCount() + ' user records with a blank company field.');

    // Iterate over each record.
    while (gr.next()) {
        // Log the current company value (expected to be blank).
        gs.info('Current company for user ' + gr.getDisplayValue('user_name') + ': "' + gr.company + '"');
        
        // Update the company field to "namevalue".
        gr.company = 'newcompanyvalue';
        
        // Update the record.
        gr.update();
        
        // Log the update.
        gs.info('Updated company field for user ' + gr.getDisplayValue('user_name') + ' to "PUSA".');
    }

    gs.info('Update complete.');
})();

 

 

 caller field URL "https://ourname.service-now.com/sys_user_list.do?sysparm_target=incident.caller_id&sysparm_target_va...ysparm_dependent=bc4b41b83bfc5610d957908a25e45a87&sysparm_domain_restore=false"
records found in this search 798


sys_user.list 1232 records.

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@adamabel 

company field is reference so did you give correct sysId?

        gr.company = 'sysId';
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

@adamabel 

Hope you are doing good.

Did my reply answer your question?

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

Ankur, sorry for not getting back to you.  I did pull in the correct ID doing some more testing of the issue I found that really the problem is our ServiceNOW instance when looking at the caller only wants our callers to be part of 1 company and not just listing all users in the sys_user.list. 

We have several companies that exist under our main company umbralla so is there way to adjust what the caller field filters down by?

Here is the caller url

 

https://ourcompany.service-now.com/sys_user_list.do?sysparm_target=incident.caller_id&sysparm_target...


I know the filter is related to the sysparm_dependent= but I don't know how to change that in servicenow.  It might also be the sysparm_target_value but im not sure I'm very new to servicenow so I don't fully understand its structure.