
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2018 08:00 AM
I was wondering if anyone has had any luck in populating a user's department from the user table and also allow for that department to be updated if the Requested For field is changed to another user if submitting on behalf of another employee?
I have it working by using the default value from the variable field I created that will reference the department using code I found from previous discussions on the community but I want it to work the same way if you put in a request on behalf of another user. Right now it only pulls my info and if I place another user in the Requested For field it keeps my department without updating to that users department.
This is what I have in the default value as of right now of my custom variable:
javascript:gs.getUser().getRecord().getValue("department");
javascript:gs.getUser().getRecord().getDisplayValue("department");
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2018 08:40 AM
ok, then have your GlideAjax in your onChange client script pass the value from the Requested For field...then have your script include do a GlideRecord query so the sys_user table to lookup the department field for that user to pass back to the client script. let me know if you need help with the script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2018 08:07 AM
Hello Terry,
is your "department" a variable on a catalog item or a record producer? Or is it a field on a form? Either way an onChange client script with a script include will dynamically set the "department".

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2018 08:17 AM
Patrick,
Thanks for your prompt response to my question.
I created a new custom variable called "u_edw_datagov_business_area" that references the (cmn_department) table on this catalog item.
I'm trying to find a quick basic solution script without going crazy so that it could be easily modified if needed with future enhancements.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2018 08:18 AM
Hello Terry
You can use a GlideAjax and On-change Client script to achieve this. Please refer to these articles
How to use GlideAjax and Client Scripts with Best Practice in mind
Please mark my response as correct and helpful if it helped solved your question.
-Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-01-2018 08:43 AM
Prateek,
Thank you for your response to my question. It was very helpful.