cancel
Showing results for 
Search instead for 
Did you mean: 

Task with unknown item is sent to assignee

e-no91
Champ in-the-making
Champ in-the-making
Based on a post in http://forums.alfresco.com/forum/developer-discussions/workflow/start-workflow-javascript-help-rules...,

I've edited my files:
i) bootstrap-context.xml

                <!– Review and Approve workflow definitions –>
                <props>
                    <prop key="engineId">jbpm</prop>
                    <prop key="location">alfresco/workflow/review_processdefinition.xml</prop>
                    <prop key="mimetype">text/xml</prop>
                    <prop key="redeploy">true</prop>
                </props>


ii) review_processdefinition.xml

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

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

    <swimlane name="initiator" />

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

    <swimlane name="reviewer">
        <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
            <actor>#{bpm_assignee}</actor>
        </assignment>   
    </swimlane>

    <task-node name="review">
        <task name="wf:reviewTask" swimlane="reviewer">
            <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="reject" to="rejected" >

</transition>

        <transition name="approve" to="approved" />
</task-node>

    <task-node name="rejected">
        <task name="wf:rejectedTask" swimlane="reviewer" />
        <transition name="" to="end" >
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
var dest = companyhome.childByNamePath(bpm_rejectDestination);
for (var i = 0 ; i &lt; bpm_package.children.length; i++)
{
bpm_package.children.move(dest);
}
</script>
</action>
</transition>
    </task-node>

    <task-node name="approved">
        <task name="wf:approvedTask" swimlane="reviewer" />
        <transition name="" to="end" >
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
var dest = companyhome.childByNamePath(bpm_approveDestination);
for (var i = 0 ; i &lt; bpm_package.children.length; i++)
{
bpm_package.children.move(dest);
}
</script>
</action>
</transition>
    </task-node>

    <end-state name="end" />

</process-definition>


iii) review.js

var workflow = actions.create("start-workflow");
workflow.parameters.workflowName = "jbpm$wf:review";
workflow.parameters["bpm:workflowDescription"] = "Sila review dokumen ini";
workflow.parameters["bpm:assignee"] = "us1";
workflow.parameters["bpm:approveDestination"] = "Sites/test-script";
workflow.execute(document);


I get the move my file after approval as I wanted.
The funny thing is, a task with unknown item is sent to assignee us1 everytime after us1 clicks approve during review. The item cannot be accessed at all, as if it has been moved or deleted..
What's happening here?

Is

<prop key="redeploy">true</prop>

line the cause?

EDIT: sorry, posted the wrong processdefinition code.
4 REPLIES 4

mitpatoliya
Star Collaborator
Star Collaborator

<prop key="redeploy">true</prop>


This is only to allow your changes to be picked up by JBPM.
I think in your case once you approve transition leading you to end task. And attached item is already moved that might be the reason you are not able to see anything.May be you can try moving you script piece in between transition from "approve" to "approved"

e-no91
Champ in-the-making
Champ in-the-making
But problem now is the workflow sends two tasks.
One review task is with the correct item, but once the reviewer clicks approve, this file move to the correct folder, but then, the workflow sends in a different task to review (again) of an unknown item. Do you mean that this unknown item is actually the same item that has been moved?

I'm moving the codes now, will update soon.

kaynezhang
World-Class Innovator
World-Class Innovator
It seems those code you pasted out will not trigger  sending another  task to review (again).
you can turn debug log on and add some log information in your script to trace what cause your review task created twice and what on earth  "unknown item" is

I don't think it is caused by
<prop key="redeploy">true</prop> 
,this flag tells alfresco whether or not it should automatically redeploy the process on startup. 

e-no91
Champ in-the-making
Champ in-the-making
Thanks for the explanation.
I use the same code on review_pooled_processdefinition, and it works. I must have missed something on review_processdefinition..