Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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

Community Alums
Not applicable

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

Abhinay Erra
Giga Sage

Well try this


gs.getUser().getRecord().getValue('department');



Note: getRecord() does not return GlideRecord, it returns GlideMemoryRecord which is a cached version of GlideRecord.


Community Alums
Not applicable

I tried that and it gave me an error that getRecord() wasn't allowed in a scoped app.


Chuck Tomasi
Tera Patron

I've sent this thread off to our platform business unit. Personally, I think it's sad that gs.getUser().getDepartmentID() doesn't work in a scoped app.


Community Alums
Not applicable

Thanks Chuck, I agree.   There isn't any reason I can think of that the getUser() is so limited in scoped apps.