Get User Information in JavaScript task

What is the best way to obtain the following user information within a Script (JavaScript) task. I have searched for examples but can’t find any?

  1. User name and email for process initiator?
  2. User name and email of the user who completed the previous task?
  3. Emails for users on a particular group?

Is there a reason you specifically want a script task? It makes things a bit cumbersome to write and test.

If you’re using the out of the box users and groups, the answers would be:

  1. The initiator is stored as a variable (defined by flowable:initiator). This is the userId. Use this userId to fetch, via the identityService, the other bits of information.
  2. If the script task is immediately after the user task, the transaction won’t have been committed yet. You could store the assignee id of the previous task using a TaskListener and put the id in a (transient) variable for example and use same mechanism in (1) to get the info.
  3. You’d need to do a UserQuery for a particular group and simply loop over the results.

Thank you for the information. I need to do this in a Javascript or Groovy task because I need end-users who using the modeler application can set assignments dynamically.

Jaime,

You managed to get these results?

Not using the script. I am in the process of implementing a task listener.