cancel
Showing results for 
Search instead for 
Did you mean: 

Update Custom Workflow Properties

swemon
Champ on-the-rise
Champ on-the-rise
Dear all,

I want to know how to update workflow properties like bpm_workflowPriority or custom properties (for eg. dmswf_workflowStatus)with java or javascript.
<transition name="reject" to="rejected" >
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <runas>admin</runas>
              <script>
               logger.log("Workflow Status"+ dmswf_workflowStatus);
               dmswf_workflowStatus = "Rejected";
               
            </script>
         </action>
      </transition>

Thank in adv.
1 REPLY 1

swemon
Champ on-the-rise
Champ on-the-rise
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");
    }

}