Auto populate Country field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2024 04:46 AM
Hi All,
I want a script to Auto Populate the country field based on the Requester field.
I tried onchange client script, But Iam getting undefined as mapping.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2024 04:55 AM
HI @Negha1 ,
Apply OnChange client script ....
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || isTemplate) {
return;
}
var requesterField = g_form.getValue('requested_for');
if (requesterField) {
var countryField = g_form.getValue('country');
if (countryField === '') {
var grUser = new GlideRecord('sys_user');
grUser.get(requesterField);
if (grUser.hasAttribute('country')) {
g_form.setValue('country', grUser.getValue('country'));
}
}
}
}
Hope it will work
If this is helpful for you, Please mark Helpful and Correct solution
Thanks & Regards
Adarsh Verma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2024 03:04 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2024 05:41 AM