- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2023 09:57 PM
in catalog form i need to autopopulate field like location, phone no etc. i written script include and client script.
but it's not fetching value.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2023 10:13 PM - edited 08-08-2023 10:17 PM
Hello @Gillerla Rajesh ,
try below code
Client Script :
// Client script for onChange on change of requestor
function onChangeUser() {
var requester = g_form.getControl('requester'); // Replace 'requester' with the actual field name
// Create a GlideAjax instance and specify the script include name
var ga = new GlideAjax('CustomUserUtils'); // Replace 'CustomUserUtils' with your actual script include name
ga.addParam('sysparm_name', 'getUserInfo'); // script include function name
ga.addParam('sysparm_user', requester);
ga.getXML(getResponse);
function getResponse(response) {
var answer = response.responseXML.documentElement.getAttribute('answer');
if (answer) {
var userInfo = JSON.parse(answer);
g_form.setValue('location_field', userInfo.location);
g_form.setValue('phone_number_field', userInfo.phone_number);
}
}
Script include : make sure it should be client callable
getUserInfo: function() {
var userId = this.getParameter('sysparm_user');
var userInfo = {};
var userGR = new GlideRecord('sys_user');
if (userGR.get(userId)) {
userInfo.location = userGR.location.getDisplayValue();
userInfo.phone_number = userGR.phone.getDisplayValue();
}
return JSON.stringify(userInfo);
},
Kindly mark correct and helpful if applicable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2023 01:32 AM
You can do one thing change the data type of location as Reference to "cmn_location" table, it will work 100%
If my answer solved your issue, please mark my answer as ✅ Correct & 👍Helpful based on the Impact.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2023 10:26 PM
Hello if your using Utah version, you dont need a script to populate, use autopopulate option under variable
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2023 09:02 AM
may I ask why you accept the complicated, error-prone solution with scripting if you can have a no-code solution as proposed by me?
Just want to know why you don't use the provided OOTB features and instead want to increase the risk of broken functionalities.
Maik