What is the best way to get gs.getUser().getDepartmentID() in a scoped script?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2016 08:53 AM
I'm trying to set the default value of the department field on a scoped table and this doesn't seem to work since the scoped API is limited, is there a simpler way than a full GlideRecord query?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2023 03:11 PM
I can't believe this is still an issue! It seems like javascript:gs.getUser().getDepartmentID(); works for me though.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2016 10:57 AM
Sorry, I cannot see any other option other than GlideRecord
var gr= new GlideRecord('sys_user');
gr.get(gs.getUserID());
gr.department;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2016 11:00 AM
I found a solution, but it's odd. I created a dynamic filter that uses, gs.getUser().getDepartmentID(), and then used that in the Scoped table default value and it seems to work. Not sure why it works that way but not directly, but I'll take it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2018 07:55 AM
hey what did you put in the reference table field ? [sys_user] table or Department [cmn_department] table ? thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-01-2023 03:12 PM
I used "javascript:gs.getUser().getDepartmentID();"