How can we automatically populate the Site field value based on the Caller field.

Ria
Tera Contributor

How can we automatically populate the Site field value based on the Caller field for a specific catalog item?

Currently, both the Caller and Site fields are populated automatically. However, if the caller's name is changed, the site value does not update accordingly.

25 REPLIES 25

Shubhras
Tera Contributor

Hello @Ria 

To automatically update the Site field based on the Caller field in a catalog item, you can create a catalog client script of type onChange on the Caller variable. This script will run every time the Caller value is changed by the user.

Inside the script, you use a GlideAjax call to send the selected caller's user ID to a Script Include that looks up the user's location field (which typically represents the Site). The Script Include returns the corresponding Site value, and then the client script sets that value into the Site field.

This ensures that whenever the Caller changes, the Site field is automatically refreshed with the correct location tied to the new Caller.

 

Kindly mark my answer as helpful and accept solution if it helped you. 

Regards,
Shubhra

 

 

 

 

Ria
Tera Contributor

Hi @Shubhras

 

Could you please provide me the scripts?

Community Alums
Not applicable

You can do it multiple ways. Mostly people choose Onchange Client Script to do this. Another option will be SetValue under UI policy.

Ankur Bawiskar
Tera Patron
Tera Patron

@Ria 

Is caller a reference variable & is site a string variable?

if yes then you can use auto populate feature and no scripting required

Auto-populate a variable based on a reference type variable (Utah) 

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