AnsweredAssumed Answered

Workflow in share and alfresco

Question asked by sokolko on Apr 2, 2012
Latest reply on Apr 2, 2012 by sokolko
Hello, all!
Recently I've come across quite an interesting thing about alfresco's old web UI (alfresco) compared to the new Alfresco Share. In our project we want a user to see his started workflows and their current states. So, alfresco share has the needed functionality. But when I create an advanced workflow and try to execute it in share, the user doesn't see the transitions of this workflow. There is a task in "My tasks" list, but no actions can be taken. Nevertheless, all alfresco built-in advanced workflows work perfectly. My custom workflow also works fine in alfresco old UI. So, maybe anyone knows, what could be the reason?

my process definition:

<?xml version="1.0" encoding="UTF-8"?>

<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="wf:Multiadhoc">

    <swimlane name="initiator" />

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

           <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
               <script>
               <variable name="bpm_workflowDescription" access="read,write" />
               <variable name="bpm_package" access="read" />
                <expression>
                   bpm_workflowDescription = bpm_package.children[0].properties["tc:sender_type"] + " " + bpm_package.children[0].properties["tc:company"] + " - " + bpm_package.children[0].properties["tc:topic"] + " " + bpm_workflowDescription;
                </expression>       
               </script>
           </action>


        </transition>

      <event type="node-leave">
             <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
                <script>
                 var now = new Date();

                 var hour = now.getHours();
                 var min = now.getMinutes();
                 var day = now.getDate();
                 var month = now.getMonth();
                 var year = now.getFullYear();

                 var name=year.toString() + "-" + month.toString() + "-" + day.toString() + "-" + hour.toString() + "-" + min.toString() + "-";

                     var i=0;
                     var k=bpm_package.children.length;
                     for (i=0; i &lt; k; i++)
                     {
                      
                       bpm_package.children[i].properties["cm:name"] = name + bpm_package.children[i].properties["cm:name"];
                       bpm_package.children[i].save();
                       bpm_package.children[i].move(companyhome.childByNamePath("Подшивка"));
                     }
                </script>
              </action>
         </event>  

    </start-state>

    <node name="startreview">

        <action class="org.alfresco.repo.workflow.jbpm.ForEachFork">
            <foreach>#{bpm_assignees}</foreach>
            <var>reviewer</var>
        </action>
        <transition name="review" to="review"/>
    </node>

    <task-node name="review">

        <task name="wf:submitParallelReviewTask">
            <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
               <actor>#{reviewer}</actor>
            </assignment>
            <event type="task-create">
                <script>
                    if (bpm_workflowDueDate != void) taskInstance.dueDate = bpm_workflowDueDate;
                    if (bpm_workflowPriority != void) taskInstance.priority = bpm_workflowPriority;
                </script>
            </event>
        </task>
        <transition name="Выполнено" to="endreview" />
<transition name="Передать" to="endreview">
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
   <script>
        <variable name="bpm_package" access="read"/>
        <variable name="bpm_assignees" access="read"/>
   <variable name="bpm_workflowDueDate" access="read"/>
   <variable name="bpm_workflowPriority" access="read"/>
   <variable name="bpm_workflowDescription" access="read"/>
        <expression>
var workflowDefinition = workflow.getDefinitionByName("jbpm$wf:adhoc");
var workflowPackage = workflow.createPackage();
for (var j=0; j &lt; bpm_package.children.length; j++)
{
   workflowPackage.addNode(bpm_package.children[j]);
}
var workflowParameters = new Array();

workflowParameters["bpm:workflowDueDate"] = bpm_workflowDueDate;
workflowParameters["bpm:workflowDescription"]=bpm_workflowDescription;
workflowParameters["bpm:workflowPriority"]=bpm_workflowPriority;

for(var j = 0; j &lt; bpm_assignees.size(); j++)
{
   workflowParameters["bpm:assignee"] = bpm_assignees.get(j);
   var workflowPath = workflowDefinition.startWorkflow(workflowPackage, workflowParameters);
   var tasks = workflowPath.getTasks();
   for (task in tasks)
   {
         tasks[task].endTask(null);
   }

}


        </expression>
        </script>
        </action>
        </transition>
    </task-node>

<join name="endreview">
        <transition to="end" />
    </join>


 

    <end-state name="end"/>

</process-definition>

Outcomes