Reputation: 5946
I want to update custom workflow properties(workflowStatus) in task transition. In detail, when I approve the workflows workflowStatus changed to "Approved", and at the time I reject, this property changed to "Rejected".
How can I do?? Writing with Javascript or other separate java file like AlfrescoJavaScript?? I use jbpm workflow.
Upvotes: 0
Views: 1043
Reputation: 5946
Now I can solve it. I write my own action class for each transition such as CustomWorkflowApprove and CustomWorkflowReject. In these class I update workflow properties. Part of my processdefinition.xml is as follows:
<task-node name="approve2">
<task name="dmswf:reviewTask2" swimlane="approver2">
<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="approve" to="approved" >
<action class="org.ace.dms.bean.CustomWorkflowApprove"/>
</transition>
<transition name="reject" to="rejected" >
<action class="org.ace.dms.bean.CustomWorkflowReject"/>
</transition>
</task-node>
This is my CustomWorkflowAction class.
package org.ace.dms.bean;
import org.alfresco.repo.workflow.jbpm.JBPMSpringActionHandler;
import org.jbpm.graph.exe.ExecutionContext;
public abstract class CustomWorkflowAction extends JBPMSpringActionHandler {
public static final String APPROVE = "Approved";
public static final String REJECT = "Rejected";
public static final String WORKFLOWSTATUS = "dmswf_workflowStatus";
public void updateWorkflowProperties(ExecutionContext context,
String workflowStatus) {
//update custom workflow property dmswf_workflowStatus, you can update any workflow property here
context.setVariable(WORKFLOWSTATUS, workflowStatus);
}
}
This is my CustomWorkflowApprove class.
package org.ace.dms.bean;
import org.jbpm.graph.exe.ExecutionContext;
import org.springframework.beans.factory.BeanFactory;
public class CustomWorkflowApprove extends CustomWorkflowAction {
@Override
public void execute(ExecutionContext context) throws Exception {
updateWorkflowProperties(context, CustomWorkflowAction.APPROVE);
}
@Override
protected void initialiseHandler(BeanFactory factory) {
// TODO Auto-generated method stub
System.out.println("Initialzize Handler");
}
}
Upvotes: 1