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

User151789
Mega Contributor

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?

9 REPLIES 9

I can't believe this is still an issue! It seems like javascript:gs.getUser().getDepartmentID(); works for me though.

Abhinay Erra
Giga Sage

Sorry, I cannot see any other option other than GlideRecord



var gr= new GlideRecord('sys_user');


gr.get(gs.getUserID());


gr.department;


User151789
Mega Contributor

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.


hey what did you put in the reference table field ? [sys_user] table or Department [cmn_department] table ? thanks


I used "javascript:gs.getUser().getDepartmentID();"