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.

gs.getUser() in script include called from scoped app not working as expected

Ron28
Mega Sage

I have a scoped app where I need to check if the logged in user is in a certain team. As gs.getUser().isMemberOf() doesn't work in a scoped app, I moved that to a script include. But gs.getUser() still doesn't work as expected, the user shows as  'com.glide.sys.User@...........' when writing to system logs. As a result gs.getUser().isMemberOf() always returns false.

I could query the system tables but as I don't have the correct user object I'm not sure that will work either. Does anyone have a workaround for this?

 

Thanks

Ron

1 ACCEPTED SOLUTION

Yup, that should work. The method to use is:

 

gs.getUserID()

View solution in original post

5 REPLIES 5

Ron28
Mega Sage

I've changed properties on the flow to run as "user who initiated the session" instead of "system".  Now gs.getUser works as expected. 

Thanks for your input!

Ron