How to get the name of a user that submited a task

Hello, I’m trying to get the name of the user that submitted a task, I’m doing it this way

import org.bonitasoft.engine.bpm.process.ProcessDefinition;
    
    Long processId = processDefinitionId.longValue();
    String userName = apiAccessor.identityAPI.getUser( apiAccessor.processAPI.getLastStateHumanTaskInstance(processId, "Task Name" ).getActorId() ).getUserName();

i try to get the user by retrieving the last human task, getting it’s actorsId and sending it to getUser and finally using it’s method getUserName()
but It does not found the task
i’m using bonita 7.4.3

what i’m doing wrong?
Regards.

Update
If you where looking for this

well apparently the user does not exist out of the UI, so you have to use the RestAPI to get the data of the user, i have used an alternative where i get the info in the task and return it by the contract and get it into a variable to use it later

first you need to get the session with
…/API/system/session/unusedId

then the user with
…/API/identity/user/{{session.user_id}}

1 Like

you can get the same information using REST API. Its much simpler.

Get all current tasks - /bonita/API/bpm/task?c=100&p=0&f=parentCaseId={{caseId}}
Get all completed tasks - /bonita/API/bpm/archivedHumanTask?p=0&c=100&f=caseId={{caseId}}

Regards

thanks.