- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2020 09:28 AM
Hi,
I am attempting to create a variable set that automatically fills in the following information for use on catalog items and record producers. (variable name in parentheses)
User who opened the request (requesting_user)
User's department (users_department)
User's manager (users_manager)
The requesting user fills in because I have the default value set to javascript:gs.getUserID()
Below are the OnLoad and OnChange scripts i have written
function onLoad(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
g_form.getReference('requesting_user', setFields);
}
function setFields(user) {
g_form.setValue('users_manager', user.manager);
g_form.setValue('users_department', user.department);
}
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
g_form.getReference('requesting_user', setFields);
}
function setFields(user) {
g_form.setValue('users_manager', user.manager);
g_form.setValue('users_department', user.department);
}
What am I doing wrong here?
Thank you in advance for your responses
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2020 01:41 PM
Resolved the issue. Please try now 🙂
Here are the modification
1. Set client script UI type to all. This is required to trigger script in Service Portal
2. Update OnChange CS to include variable name.
3. Updated Department variable to point to department table and not sys_user.
I hope this helps.
- Pradeep Sharma

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2020 09:32 AM
Hi Matt,
Replace g_form.getReference('requesting_user', setFields); with var user = g_form.getReference('requesting_user', setFields);
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var user = g_form.getReference('requesting_user', setFields);
}
function setFields(user) {
g_form.setValue('users_manager', user.manager);
g_form.setValue('users_department', user.department);
}
- Pradeep Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2020 10:26 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2020 11:34 AM
Hi Matt,
Could you please reproduce this on the PDI instance and share the instance URL with me?
- Pradeep Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2020 01:12 PM