- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2019 12:14 PM
Hi all,
I need to autopopulate manager in the manager variable on catalog form for the request for field.
I can add to the default value - javascript:gs.getUser().getManagerID(); and it autopopulates the manager, however if the request for name is changed (for example if an EA is logging on behalf of they would change the request for field name from them to other person) - then the manager field does not update to reflect that changed users manager (stays to the logged in users manager), is there any simple code to update the manager onChange, I am guessing I need catalog client script?
thanks.
Solved! Go to Solution.
- Labels:
-
Personal Developer Instance

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2019 12:24 PM
If you looking for something on the client side, you can do it using getReference
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var usr = g_form.getReference('requested_for',callBack);
}
function callBack(usr){
g_form.setValue('manager',usr.manager);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2019 12:18 PM
You need to write an onchange catalog client script. Select the type as "OnChange" and variable name to the "Requestors field".
Here is the script which you need.
var user = g_form.getValue('requested_for');
var mgr = new GlideRecord("sys_user");
mgr.addQuery("sys_id",user);
mgr.query();
if(mgr.next())
{
g_form.setValue("manager",mgr.manager);
}
Please mark this answered if this response helps. Let me know if you have any questions.
Thanks,
Raghu.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2020 06:05 AM
no

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2019 12:18 PM
I think you just need to a run script in the workflow at the beginning with something like this.
current.variables.[variable name] = current.request.request_for.manager;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2019 12:22 PM
Another thought that brought me to a question: Is the requested_for that you are talking about a variable on your form or is it the request_for you see when checking out?