cancel
Showing results for 
Search instead for 
Did you mean: 

Exception when assign workflow to assignees

zengqingyi12
Champ in-the-making
Champ in-the-making
right now I am working on alfresco share preview 2.
there is no build in workflow that can assign multiple assignees, so i should do it by myself,
there is such code in assign_workflow.post.json.js

// Get the workflow definition
var workflowDefinition = workflow.getDefinitionByName(workflowName);

// Create the workflow package to contain the file nodes
var workflowPackage = workflow.createPackage();

if (assignees.length == 1)
{
workflowParameters["bpm:assignee"] = assignees[0];
}
else
{
workflowParameters["bpm:assignees"] = assignees;
}

var workflowPath = workflowDefinition.startWorkflow(workflowPackage, workflowParameters);

so when there multiple assignees, it will assign all the assignees array to workflowParameters["bpm:assignees"]

//process define

<start-state name="start">
<task name="wf:submitAdhocTask" swimlane="initiator"/>
<transition name="" to="adhoc"/>
</start-state>

//model define
<type name="wf:submitAdhocTask">
<parent>bpm:startTask</parent>
<properties>
<property name="wf:notifyMe">
<type>d:boolean</type>
<default>false</default>
</property>
</properties>
<mandatory-aspects>
<aspect>bpm:assignees</aspect>
</mandatory-aspects>
</type>

but the buildin adhoc workflow only have a mandatory aspect that accept one assignee, so I change the
<mandatory-aspects>
<aspect>bpm:assignee</aspect>
</mandatory-aspects>
to
<mandatory-aspects>
<aspect>bpm:assignees</aspect>
</mandatory-aspects>

and when I try to assign workflow to multiple assignees, it will cause a cast class exception —–arraylist exception.
I have tries many method to find out the problem, but i failed.
what can i do to figure out the problem ?
anyone knows where the alfresco convert javascript array into java arraylist and then save into repository ???
where is the class that actually do these kind of work locate in ??
Thanks very much !
6 REPLIES 6

mikeh
Star Contributor
Star Contributor
Hi

Although I've not tested it, the following line in the original code looks a bit odd:
#57:       assignees[i] = [people.getPerson(assignees[i])];
I suspect you need to remove the array brackets around the right-hand side.

Thanks,
Mike

zengqingyi12
Champ in-the-making
Champ in-the-making
yes, you are right, when i debug the code the original code will form such a array[[],[],[]]  , and I think the jpdm need a [ , ] array.
but when i remove the bracket, it still can not assign adhoc to multiple assignees,
could you please help me ?
Regards,
Dennis

mikeh
Star Contributor
Star Contributor
What's the new exception after the code change? Same one..?

Mike

zengqingyi12
Champ in-the-making
Champ in-the-making
It seems that the adhoc model has cached or other reasons, i still cann't find the problem.

There is another exception:    bpm:assignee is not defined.   
What a strange problem! I do never change the bpmmodel's definition!


could you please tell me how alfresco communicate with jboss workflow ? just use jpdl ?

mikeh
Star Contributor
Star Contributor
Did you redeploy the workflow? Note that in-flight workflows won't be updated.

See the wiki notes on the Workflow Console and Workflow Administration

Thanks,
Mike

zengqingyi12
Champ in-the-making
Champ in-the-making
Thanks so much, that's exactly where the problem is.