How to retrieve the group from a user who started the process

Hello ,
I would retrieve in Start Event of a BPM Process, the Group of user who started the process.
It is possible with a Listener?
Can you give me some examples that i could use ?
Thanks

@oronzo_lezzi, StartedBy is persisted in the history tables. You can access like this:

public class StartEventExecutionListener implements ExecutionListener {

  @Override
  public void notify(DelegateExecution execution) throws Exception {
    execution.getProcessEngineServices().getHistoryService().createHistoricProcessInstanceQuery().active()
        .startedBy("userId");
  }
}

Configure the execution listener in the StartEvent of the process where event type = “end”.

image

Thank you @aravindhrs for your quick response. I cannot understand How to get the group of the user.
I would check the groupId and I want to set an environment variable to the user’s groupId found

Which one are you referring to? candidate starter groups or candidate starter users?

Permission will be set to group of users or list of groups, but from the list, only one user can start the process. Multiple user’s can’t start the same process instance.

It’s a privilege given to the list of users, among them anyone can start the process instance

Hello this is my process


I would retrieve the group whose user has started who start the process ( with Start Event “Inserimento Richiesta”) and assign the user task “Approvazione richiesta primo livello” to another user ( “Approver”) is part of the same group.
It is possible ?

@oronzo_lezzi , Candidate Starter Groups attribute is in Process level, not the activity (start event) level. So in order to access the group name, you need to get BpmnModelInstance, from that you can access the groups.

Hello @aravindhrs thanks for your answer. For me it’s very difficult to understand how to retrieve Candidate Group from BpmnModelInstance. I’m not a developer.
It is necessary a Service Task at this point ?
Do you have Java code (or JavaScrpit) example?

Good morning @aravindhrs i have changed my BPM process, as I wrote in this post