gs.getUserId return value 'system'

amber
Tera Contributor

Hello Experts, 

I feel strange when I'm using Glide system API method gs.getUserID in script include, it just returns 'system' instead of the sys_id of the current user. And also other methods related all return 'system'. Do you know the reason for it? 

 

Thanks & Regards

Amber 

1 ACCEPTED SOLUTION

Hitoshi Ozawa
Giga Sage
Giga Sage

Amber,

Can it be that Script Include is being executed from email? gs.getuserID() will return sys_id of the currently executing user. In case of email or scheduled jobs, this can be "system".

See simiilar question in the following thread.

https://community.servicenow.com/community?id=community_question&sys_id=f216ff81dbbe805814d6fb243996...

View solution in original post

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

in whose session the script is running and where it is written?

please provide some more details and screenshots for that

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

It is written in a script include which is called from a flow action. 

 

Here is where I used: 

 

roleHas.addQuery('user', gs.getUserID());

Hi,

Flow is configured to Run as System or User session?

share flow properties screenshot

find_real_file.png

Share details as Flow is running on which table? in which step you are using the query/script?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hitoshi Ozawa
Giga Sage
Giga Sage

Hi Amber,

Try running the script from Scripts Background.

gs.info(gs.getUserID());