- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2018 01:00 PM
Can some one give me the code for getting the logged in user department
I tried gs.getUser().getDepartmentID(); and getDepartmentID() none of them worked
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2018 07:55 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2018 02:34 PM
Can we give a try,
var gr=new GlideRecord('sys_user');
gr.get(gs.getUserId());
var obj=new GlideRecord("u_data");
obj.initialize();
obj.table='u_data';
obj.u_accepted_user= gs.getUserName();
obj.u_department = gr.department.toString();
obj.insert();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2018 06:16 AM
Not working 😞

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2018 07:09 AM
Correction in the script,
var gr=new GlideRecord('sys_user');
gr.get(gs.getUserID());
var obj=new GlideRecord("u_data");
obj.initialize();
obj.table='u_data';
obj.u_accepted_user= gs.getUserName();
obj.u_department = gr.department.toString();
obj.insert();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2018 07:21 AM
Try below code once,
var user = new GlideRecord('sys_user');
if(user.get(gs.getUserID() ){
var obj=new GlideRecord("u_data");
obj.initialize();
obj.table='u_data';
obj.u_accepted_user=gs.getUserID();
obj.u_department= user.department;
obj.insert();
}
hope this helps.
Hit Like / Helpful / Answered as applicable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2018 01:41 PM
If you want Department display value as of when the user logged in, this appears to work:
gs.getUser().getRecord().getDisplayValue("department")