- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2023 02:17 AM
Hi
i am writing a catalog client script for auto populating user fields, whenever the user is changed the fields related to that user (ex; first ,last name should auto populate)which the fields are referencing to HR profile table in our case not the user table
its working fine for the customized fields which we designed in hr profile table(Title,project end date etc), but the OOTB fields which were already there in HR profile record like first name ,those were referencing to user table so the script is not working for these fields
pasting the code here//
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
g_form.getReference('contractor_name', callBack);
function callBack(user) {
g_form.setValue(first_name,user.user.first_name);
g_form.setValue(last_name,user.user.last_name);
g_form.setValue('u_title', user.u_title);
g_form.setValue('u_project_end_date', user.u_project_end_date);
g_form.setValue('u_hire_date', user.u_hire_date);
g_form.setValue('u_person_type', user.u_person_type);
g_form.setValue('u_executive', user.u_executive);
g_form.setValue('u_remote', user.u_remote);
g_form.setValue('u_hiring_manager',user.u_hiring_manager);
}
}
@Ankur Bawiskar @Vaishnavi Lathk
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-03-2023 02:45 AM
please use GlideAjax and you can dot walk to multiple levels.
Return those values from script include and set in client side
Get User Details based on the Logged in user/ User selected in Client Script
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-03-2023 03:04 AM
Hello @sri vijaya ,
I Hope you are doing well!
you haven't Declare the variable for dot walk.
var user = g_form.getReference('contractor_name', callBack);
In the ServiceNow you cannot dot walk to 2 levels.Instead of that Refer GlideAjax as Mentioned by Ankur and Chetan.
FYR,
Regards,
Vaishnavi Lathkar