cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple ways to define assingers in FORK nodes

ale_carraro
Champ in-the-making
Champ in-the-making
Hi, I got to FORK a workflow execution setting assignees equal to a "distribution list", eg a list of people defined in a group in this way.

 <node name="sign">
   <action class="org.alfresco.repo.workflow.jbpm.ForEachFork">
    <foreach>#{people.getMembers(people.getGroup('GROUP_signers'))}</foreach>
    <var>reviewer</var>
   </action>

Now, I want to give he possibility to add (but not to remove) people from the workflow task instance, so I put an association with multiple person nodes.

However I can't implement this enhancement, since <node> element support only one action, and putting more than one action in an event such as node-leave give me the javascript error "reviewer is not defined".

Does anybody has an hint on this?

Thanks in advance

Alex
5 REPLIES 5

ale_carraro
Champ in-the-making
Champ in-the-making
I did a step further:
Instead of putting more than one action, I merged the collections of people in this way (bw_ulterioriFirmatari is the variable containing the UI selected people)


<action class="org.alfresco.repo.workflow.jbpm.ForEachFork">
    <foreach>
      #{people.getMembers(people.getGroup('GROUP_signers')).concat(bw_ulterioriFirmatari)}
    </foreach>
    <var>reviewer</var>
</action>

The model defining bw_ulterioriFirmatari is the following:
                <association name="bw:ulterioriFirmatari">
                    <source>
                        <mandatory>false</mandatory>
                        <many>false</many>
                    </source>
                    <target>
                        <class>cm:person</class>
                        <mandatory>false</mandatory>
                        <many>true</many>
                    </target>
                </association>

Now the proble is a Javascript one:

the 2 collections seem not compatible:
people.getMembers(people.getGroup('GROUP_signers')) return a list of Nodes,
bw_ulterioriFirmatari return 1 object that is the array containing the Nodes. So merging it i got something NodeA,NodeB,NodeC,…,Array(NodeD,NodeE,…)

How do I merge the 2 collections?

thanks

ale_carraro
Champ in-the-making
Champ in-the-making
I was able to get the two collections merged, in this way:

            <action class="org.alfresco.repo.workflow.jbpm.ForEachFork">
               <foreach>#{
               a = new java.util.ArrayList(java.util.Arrays.asList(people.getMembers(people.getGroup('GROUP_signers'))));
               a.addAll(bw_ulterioriFirmatari);
               a;}</foreach>
               <var>reviewer</var>
           </action>

However, now I get a NotSerializableException when saving the ScriptNode object returned by people.getMembers(people.getGroup('GROUP_signers'))…

Any ideas?

Thanks

Alex

ale_carraro
Champ in-the-making
Champ in-the-making
ok, I'm almost did it. I post here the solution of the puzzle…

a = new Array(); a = a.concat(people.getMembers(people.getGroup('GROUP_signers')));
if(typeof bw_ulterioriFirmatari != 'undefined')
   for(var i = 0; i &lt; bw_ulterioriFirmatari.size(); i++)
      a = a.concat(bw_ulterioriFirmatari.get(i).getNodeRef());

the
people.getMembers(people.getGroup('GROUP_signers'))
return an ArrayList of NodeRef instances, while the process variable bw:ulterioriFirmatari (that is definde as a multiple association to cmSmiley Tongueerson), is resolved by the javascript engine as a single object, a JBPMNodeList, that is more or less an ArrayList of JBPMNode.
Using them separarately works because after evaluating the script, the reslut is converted in an ArrayList of JBPMNodes. Alfresco do it a node at a time, but only if the objects in the list is made of the same objects.
My solution is to get NodeRef from JBPMNodes, so Alfresco can convert them to JBPMNodes!…

Unfortunately, I could not find a way to get a list of cmSmiley Tongueerson out of the list of groups. The group list resolves to the JBPMNodeList, but here the nodes are instances of the groups and not of the persons involved. I tried to call people.getMembers() on this nodes, but strangely it do not work. I say it is strange, because JBPMNode IS a ScriptedNode, and so the method is defined, but it seems that JBPMNodes when dealing with groups are not instanced with their properties, they have just the id.

Can anyone tell me if there is a way to get the properties such as {http://www.alfresco.org/model/user/1.0}members from the NodeRef object?

thanks

Alex

rosa_martin
Champ in-the-making
Champ in-the-making
Hello

Your solution helped me a lot.
I was mad with the use of ForEachFork to create n tasks that are not sent necessarily to n "people", but other type of contents (for example, documents).
Your solution also works if you create an array of an association of documents:

      <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
        <script>          
          <variable name="listaDocs" access="write" />
          <expression>
              listaDocs = new Array();
              for(var i = 0; i &lt; wfedmp_NodoDoc.size(); i++)
                listaDocs = listaDocs.concat(wfedmp_NodoDoc.get(i).getNodeRef());
          </expression>
        </script>
      </action>

And define the fork like:

    <action class="org.alfresco.repo.workflow.jbpm.ForEachFork">
      <foreach>#{listaDocs}</foreach>
      <var>ADoc</var>
    </action>

Thank you very much

carlos_miguens
Champ on-the-rise
Champ on-the-rise
An excellent post Alex.