cancel
Showing results for 
Search instead for 
Did you mean: 

How to get bpm_assignee username?

upforsin
Star Collaborator
Star Collaborator

The user is choosing bpm_assignee in the UserTask.

Now how can I get the username of this bpm_assignee in Java/Javascript?

I know i can use ${bpm_assignee.properties.userName} in the process definition. But I have to get the username in the taskListener or ServiceTask.

I tried almost everything but but nothing seems to work.

  I tried to fetch bpm_assignee by:

Object assignee = execution.getVariable("bpm_assignee");‍‍

but then there is nothing i can do with this object. When I print I get:

Node Type: {http://www.alfresco.org/model/content/1.0}person, Node Aspects: [{http://www.alfresco.org/model/content/1.0}ownable, {http://www.alfresco.org/model/system/1.0}cascadeUpdate, {http://www.alfresco.org/model/system/1.0}referenceable, {http://www.alfresco.org/model/system/1.0}localized]

When I invoke getDeclaredFields(), only serialVersionUID is shown,

When I invoke getVariableInstance() I get:

VariableInstanceEntity[id=32615, name=bpm_assignee, type=alfrescoScriptNode, textValue=workspace://SpacesStore/3a93aa03-b6b7...]

assignee.properties.userName is undefined (or null).

What can I do?

Regards,

Mike

howkymike
Alfresco Developer
1 ACCEPTED ANSWER

upforsin
Star Collaborator
Star Collaborator

OK, I set up the debugger and it happened to be very simple.

Previously i tried: execution.getVariable("bpm_assignee").getProperties().get("userName");

But the solution is:

String name= execution.getVariable("bpm_assignee").getProperties().get("{http://www.alfresco.org/model/content/1.0}userName");

Or in Javascript

bpm_assignee.properties.userName
howkymike
Alfresco Developer

View answer in original post

2 REPLIES 2

upforsin
Star Collaborator
Star Collaborator

OK, I set up the debugger and it happened to be very simple.

Previously i tried: execution.getVariable("bpm_assignee").getProperties().get("userName");

But the solution is:

String name= execution.getVariable("bpm_assignee").getProperties().get("{http://www.alfresco.org/model/content/1.0}userName");

Or in Javascript

bpm_assignee.properties.userName
howkymike
Alfresco Developer

vidhipanchal
Star Contributor
Star Contributor

Hi,
You can also use "delegateTask.getAssignee();" to get assignee of UserTask.

Thanks,

Vidhi

ContCentric

Regards,
Vidhi