Auto populate Location(location) Based on the Users selection.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2023 10:27 PM
My Requirement is in service catalog request we have two variables
1) reee_joiner_name (Type=Reference. Reference table is "sys_user")
2)Location(Type=SingleLine Text)
When we select the reee_joiner_name , Location will be autopopulate based on the reee joiner name for user.
I have written the below Onchange catalog client script ::
var Rejoin = g_form.getReference('reee_joiner_name',callback);
function callback(Rejoin){
g_form.setValue('phone_number',Rejoin.mobile_phone);
g_form.setValue('location',Rejoin.location);
}
According to this code Phone number will displaying fine. But in the Location field(location) they displaying the sys_id of the location. But my requirement is displaying Location name.
Please help me Regarding this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2023 11:01 PM
First Approach:
You can only dot walk once in the getReference function
In order to get the display value or more dot walking you should use onChange client script with GlideAjax approach
For more info check this link
Second Approach:
Make the location field data type as Reference to locations(cmn_location) table instead of single line text, it will work for you.
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-09-2023 03:00 AM
Why not use Utah feature of Auto-populate?
It will auto-populate the variable with the field you want from reference field.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
