Company field not populating from user record to new incident

dlively
Giga Expert

When we open a new incident, the phone number is auto-populating based on the Caller as it should.   I need to figure out why the Company field is not auto-populating.

I see from the dictionary that the phone number field is coming from the User[sys_user] table,  the Type is phone number, column label is business phone, and name is phone.   There is no Choice List Specification, no Dependent field, no Calculated Value and no Default Value.

However, in the dictionary for the Company field, the Table is User [sys_user], the Type is Reference, column label is company and name is company.   The Reference Specification is Company with no qualifying condition.   There is also an Access Control called sys_user.company.   I have attached screen prints of the Access Controls.

Can someone point me in the direction of how to get the Company field to auto-populate on a new Incident record?

Thank you,

Donna Lively

8 REPLIES 8

Bharath,



I pasted your script into Client Script, (BP) Set Location to User, but it didn't seem to work. Below is the definition of our company field. Should I change the name of the field in the script to u_company, and if so, can you show me?




Thank you,



Donna Lively


(409)880-7151




Yes please, your client script should like below


script.PNG


function onChange(control, oldValue, newValue, isLoading) {


  if (isLoading)


  return;


  if (newValue == '') {


  g_form.setValue('u_company', '');


  return;


  }


  if (!g_form.hasField('u_company'))


  return;


  var caller = g_form.getReference('caller_id', setCompany);


  function setCompany(caller) {


  if (caller)


  g_form.setValue('u_company', caller.company);


  }


}


I must be missing something. It is not working.




Donna Lively


(409)880-7151




Teena Singh
ServiceNow Employee
ServiceNow Employee

Hi Donna,


Thank you for posting your query to the ServiceNow community.


The Customer Experience team is striving to ensure that customer queries are answered in timely and accurate fashion.


If you feel the question has been answered, please mark it as answered. Also, if you found the response helpful please indicate that in the thread.


Thank you in advance.



Regards,


Teena Singh


Customer Experience: UX Strategy and Customer Insights


ServiceNow