How can we automatically populate the Site field value based on the Caller field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2025 12:29 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2025 02:05 AM
No you don't need to create a new variable @Ria you can just dot walk from your existing requestor variable.
Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket.
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2025 03:50 AM
@Shivalika Could you please provide me with the catalog client script? Auto populate is impacting other fields.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2025 03:52 AM
Hello @Ria
How are you dotwalking to Site ? Can you provide me dotwalking level ? Based on that I will give only client script or both client script and script include.
Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket.
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-09-2025 03:58 AM
You didn't share your variables configured on your catalog item?
if you don't wish to use auto populate feature then check this link, which has script shared
How to Auto-Populate Location on a Catalog Item based on a User's name?
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
‎04-09-2025 04:06 AM
Hello @Ria
I am providing you a generic script - please update it accordingly.
Below 👇 is client script
var userId = g_form.getValue('requested_for');
if (!userId) return;
var ga = new GlideAjax('GetUserSite');
ga.addParam('sysparm_user_id', userId);
ga.getXMLAnswer(function(response) {
if (response) {
g_form.setValue('site', response); // assuming 'site' is the field name
} else {
g_form.clearValue('site');
}
Use this in on change client script on requestor field.
Use below 👇 script include
var GetUserSite = Class.create();
GetUserSite.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getUserSite: function() {
var userId = this.getParameter('sysparm_user_id');
if (!userId) return '';
var user = new GlideRecord('sys_user');
if (user.get(userId) && user.location) {
return user.location.site.toString(); // dot-walked site from location
}
return '';
}
});
This will return site - if both location and site exists. Modify the field names as per your requirement. And I feel if requested for was a reference field you would have dotwaalked to site field easily. No scripting required.
But since I have no screenshots can't guide easily.
Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket.
Regards,
Shivalika
My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194
My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY