- 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 01:13 PM
The Test record producer is under Office Services on the SP

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2020 01:34 PM
Thanks for the update. Could you please remove the password from your post. I am able to get to the instance.

- 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 01:52 PM
That worked! thank you so much!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-27-2020 04:46 PM
Hi Pradeep,
I have been similiar method but different layout of the code and it works fine but always thought it looked weird. Would this be considered a bad practice or could there be issue(s) doing it this way?
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue != '') {
gr = g_form.getReference('requesting_user', function(gr) {
g_form.setValue('users_manager', gr.manager);
g_form.setValue('users_department', gr.department);
});
}
}
Thanks for feedback.
-Wesley