Getting 'system' for gs.getUserID() in synchronous script action triggered by "session.established" event
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-21-2017 04:55 AM
Hi All,
I have created one synchronous script action which is getting triggered on "session.established" event.
I have written gs.getUserID() glide system function inside script action and printed with the help of log.
I am getting "system" instead of current user sys_id. Can anyone help me with this.
Regards,
Sumit

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-21-2017 05:14 AM
Can you explain what you mean by a synchronous script action? As far as I'm aware all script actions will be asyncrhonous as the event will be queued and at some point in the future processed to fire the script action. I suspect that is why you are getting the system user because the job executing the script action is being run by the system.
You can still get the user from the session.established event using event.parm1 (which is the user id). If you need to get the sys id you can do something like:
var user = new GlideRecord('sys_user');
if (user.get('user_name',event.parm1)) {
//do some stuff with user.sys_id
}
Would that work for your use case?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-21-2017 06:32 AM
thanks for reply Joe.
"session.established" event is automatically triggered by system when user log into the system. So as per my understanding there is no scope of sending parameter like event.parm1.
Please find below link for more details.
http://wiki.servicenow.com/index.php?title=Session_Client_Data#gsc.tab=0

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-21-2017 06:41 AM
There should be as well as the IP in parm2. There is even an OOB script action that uses event.parm1 with session.established. And you can see the value of parm1 on the event log ('sysevent'). The event is triggered by the system, but it has a parameter and I didn't see any indication in your link to the Session Data page to the contrary.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-21-2017 06:47 AM
Joe,
Could you please suggest me how to pass event.parm1 with current user name, so that I can retrieve it in script action.