retrieve userId in process

retrieve userId in process

Hi i want to retrieve the userid by the session.UserId in a wait onready action but it has always the value 0 .Why?
Hi Luis,

When running a process you're not running inside any user session as it is an asynchronous process (same as when you're running a timer action). Therefore the session.UserId will be the NullIdentifier.

What exactly were you trying to achieve?


i was suspicious of it ,what im trying to do is insert a record in a table that has the userid when is called a close wait .
I suppose that what you want, is to use the user id that opened/closed the activity (witch I'll assume that it is always the same one)
If that is the case you are looking for, on the OnClose, to retrieve the user id related to the activity witch the user terminated (Ended), you only need to add the Activity table to your espace (it's a system table) has you can see below

And on the OnClose action of the activity, retrieve the Activity record witch you will use to extract the userid, has below:

The Human Activity has a ActivityId that you don't see directly on the query parameter window you can see that the ActivityId appears.
After getting the activity you can get the record witch will allow you to get the user id related to the activity.

Hope this helps!
Yes i know ,but the only problem is that i checked that table activity and he userid is always filled with 0
Hi Luís,

If you want to access the session.userid inside the wait.onclose, you need to explicitely use the ActivityClose system action to close the activity.
Using database events you will not have access to the original userid.
Yes but with the ActivityClose i cant pass parameters and i have to pass a parameter on wait close
You can invoke the activity specific close and pass all the relevant parameters using the Close<ActivityName> extended action.
But that is what im doing
Can you show me your code?

When system starts the WaitCreate i want to retrieve the user that has the login and update a table with that user in the OnReady action of the wait like a human activity has the parameter user too but in this case automatically
Hi Luís,

the onready callback occurs in the context of a process as soon as the process reaches the given activity by closing the previous one (in this case the automatic activity). It is not in the context of an end user activity, and as such it doesn't have any user id associated.
Just a question, if you are waiting for something to be created (at least that's what i understand from your process flow) isn't that wait terminated when someone creates a record ?
If that is the case shouldn't that wait be a human activity that closes on the creation of the record, like that you can identify the user that managed the record creation (you can assign the human activity to a specific user or to a group of users, solving your problems on identifying the user)?