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

OlaN
Giga Sage
Giga Sage

Hi,

You can use the method gs.getUser().getID()

To get the sysID of the user, and use that to query the user from the sys_user table.

Ron28
Mega Sage

As I've just typed this up and walked away from my desk to get more coffee, I think I know why.

I'm running a flow which is triggered by a record being created, that flow runs as the system user. Which would mean I need to pass the reference to the user from the created record and do a gs.getUserByID or something, if that works in the Tokyo release.

 

Ron

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

 

gs.getUserID()

4b0d3
Giga Guru

This works for me on scope.  In PDI

4b0d3_0-1676058841578.png