- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2018 02:19 AM
I want to auto populate the Manager, Location and Department based on 'Requested_For' under Variable Set. Also want to auto populate the same when logged in user try to change the 'Requested_For'.
I tried writing "OnChange" Client script but facing an error on Portal page as "There is a JavaScript error in your browser Console". Attached the screenshot.
Also tried as per below URL but still the issue exists.
https://community.servicenow.com/community?id=community_question&sys_id=196b8b21db9cdbc01dcaf3231f96193b
Can anyone please help me with the Script?
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2018 04:45 AM
Hi Sai,
try below one-
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var gr = g_form.getReference('requested_for',callBack);
}
function callBack(gr){
g_form.setValue('manger',gr.manager);
g_form.setValue('phone_number',gr.mobile_number);
g_form.setValue('email',gr.email);
g_form.setValue('location',gr.location);
g_form.setValue('zipcode',gr.zip);
g_form.setValue('country',gr.country);
g_form.setValue('company_code',gr.company);
}
Thank you

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2018 03:14 AM
You have to modify as below
var abc = g_form.getReference('Requested_for', setUserInfo);
function setUserInfo(abc) {
if (abc){
g_form.setValue('Manager', abc.manager);
g_form.setValue('Location', abc.location);
g_form.setValue('Division', abc.department);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2018 03:35 AM
Hi Vinoth,
I tried the code as per your suggestion, but it is not populating the values.
- Sai.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2018 04:45 AM
Hi Sai,
try below one-
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var gr = g_form.getReference('requested_for',callBack);
}
function callBack(gr){
g_form.setValue('manger',gr.manager);
g_form.setValue('phone_number',gr.mobile_number);
g_form.setValue('email',gr.email);
g_form.setValue('location',gr.location);
g_form.setValue('zipcode',gr.zip);
g_form.setValue('country',gr.country);
g_form.setValue('company_code',gr.company);
}
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2018 05:16 AM
Hi Sai,
Please try below script for auto populate catalog item:
SC Client Script - function onLoad() {