Populate users department when submitting on behalf of another user

Terry Carter Jr
Tera Contributor

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");

1 ACCEPTED SOLUTION

patricklatella
Mega Sage

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


View solution in original post

9 REPLIES 9

patricklatella
Mega Sage

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".


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.  


Prateek kumar
Mega Sage

Hello Terry


You can use a GlideAjax and On-change Client script to achieve this. Please refer to these articles


GlideAjax - Resolved


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

Prateek,



Thank you for your response to my question.   It was very helpful.