cancel
Showing results for 
Search instead for 
Did you mean: 

How to set Assinees variable in alfresco execution script in workflow

alex_russ
Champ in-the-making
Champ in-the-making

Hello, i'm trying to assign bpm_assignees variable in the sequence flow, and added this code(Alfresco execution script):

var approvers = ["admin","jack"];

execution.setVariable('bpm_assignees',approvers);

And i get a error like this  "Cannot serialize native javascript array to variable".

HELP PLEASE, what i'm doing wrong?

Thanks

1 ACCEPTED ANSWER

afaust
Legendary Innovator
Legendary Innovator

You are trying to store a native JavaScript array. You must use a Java list for setting multi-valued attributes. Unfortunately creating a Java list is not possible using an inline script in a workflow definition.

Also, bpm:assignees / bpm_assignees typically is a variable on tasks - setting it on the execution can have unintentional side effects.

Is there a reason you cannot set the assignees directly on the task using BPMN constructs? As long as they are static like this there is no reason to use a script.

Also, if you want to set assignees on a task dynamically, you can use the corresponding task API operations, e.g. setAssignee(String) for a single assignee, addCandidateUser(String) to add one of multiple assignees or addCandidateUsers(Collection<String>) to add all in one (in this case the script should be able to automatically convert an array into a collection).

View answer in original post

1 REPLY 1

afaust
Legendary Innovator
Legendary Innovator

You are trying to store a native JavaScript array. You must use a Java list for setting multi-valued attributes. Unfortunately creating a Java list is not possible using an inline script in a workflow definition.

Also, bpm:assignees / bpm_assignees typically is a variable on tasks - setting it on the execution can have unintentional side effects.

Is there a reason you cannot set the assignees directly on the task using BPMN constructs? As long as they are static like this there is no reason to use a script.

Also, if you want to set assignees on a task dynamically, you can use the corresponding task API operations, e.g. setAssignee(String) for a single assignee, addCandidateUser(String) to add one of multiple assignees or addCandidateUsers(Collection<String>) to add all in one (in this case the script should be able to automatically convert an array into a collection).