cancel
Showing results for 
Search instead for 
Did you mean: 

Customize My Task Description for Workflows

karimbuenaseda
Champ on-the-rise
Champ on-the-rise
Hi All,

Upon creating a Serial Workflow for a document I want to update My Task Description so that it will reflect the "Document Name followed by Task Description"

I have been trying to do this by modifying the code below:


<?xml version="1.0" encoding="UTF-8"?>
<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="Serial Approval">
   <swimlane name="initiator" />
   <start-state name="start">
      <task name="ncm:startTask" description="Submit Serial Review Task" swimlane="initiator" />
      <event type="node-leave">

         <script>
            <variable name="approveCount" access="write" />
            <expression>approveCount = 0;</expression>
         </script>
      </event>
      <transition name="Send For Review" to="review" />
   </start-state>
   <task-node name="review">
      <task name="ncm:reviewTask">
         <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
            <actor>#{bpm_assignees.get(approveCount)}</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>
         <event type="task-assign" />
      </task>
      <event type="node-enter">
         <script>
            <variable name="reviewerCount" access="write" />
            <expression>reviewerCount = bpm_assignees.size();</expression>
         </script>
      </event>
      <transition name="Approve" to="isLast">
         <script>
            <variable name="approveCount" access="write" />
            <expression>approveCount = approveCount + 1  ;</expression>
         </script>
      </transition>
      <transition name="Reject" to="re_submit" />
   </task-node>
   <decision name="isLast">
      <transition name="No" to="review">
         <condition>#{approveCount &lt; reviewerCount}</condition>
      </transition>
      <transition name="Yes" to="FinalSubmit">
         <condition>#{approveCount == reviewerCount}</condition>
      </transition>
   </decision>
   <end-state name="end" />
   <task-node name="re_submit">
      <task name="ncm:reviewTask" swimlane="initiator">
         <event type="task-create">
            <script>if (bpm_workflowDueDate != void)

taskInstance.dueDate = bpm_workflowDueDate;

if (bpm_workflowPriority != void)

taskInstance.priority = bpm_workflowPriority;</script>
         </event>
         <event type="task-assign" />
      </task>
      <transition name="ReSubmit" to="review">
         <script>
            <variable name="approveCount" access="write" />
            <expression>approveCount =0 ;</expression>
         </script>
      </transition>
      <transition name="Finish" to="end" />
   </task-node>
   <task-node name="FinalSubmit">
      <task name="ncm:reviewTask" swimlane="initiator">
         <event type="task-assign" />
      </task>
      <transition name="Finish" to="end" />
   </task-node>
</process-definition>


every time I add the variable declarations and Java action class under the task name "ncm:reviewTask" the serial workflow does not seem to work

snippet

<task name="ncm:reviewTask">
         <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
            <actor>#{bpm_assignees.get(approveCount)}</actor>
         </assignment>
         <event type="task-create">
          <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
              <variable name="docNodeRef" access="read, write" />
              <variable name="bpm_package" access="read" />
              <expression>
              if (bpm_workflowDueDate != void)
              taskInstance.dueDate = bpm_workflowDueDate;
              if (bpm_workflowPriority != void)
              taskInstance.priority = bpm_workflowPriority;
              <expression>
            </script>
           </action>
         </event>



Am I appending the Action Class and Variable name in the correct position?

Thanks Guys,
4 REPLIES 4

mitpatoliya
Star Collaborator
Star Collaborator
this should be enough


<event type="task-create">      
            <script>         
              <expression>
              if (bpm_workflowDueDate != void)
              taskInstance.dueDate = bpm_workflowDueDate;
              if (bpm_workflowPriority != void)
              taskInstance.priority = bpm_workflowPriority;
              <expression>
            </script>
         </event>

Hi Mits,

Thanks for the prompt reply, I was thinking of getting the document name to which the workflow is attached into. I did insert the codes so that I can add the line

"bpm_package.children[0].properties["cm:name"];"


is there any other way to call "bpm_package.children" without adding the action class?

mitpatoliya
Star Collaborator
Star Collaborator
you should be able to get the name with code line you have mentioned what is the issue you are facing?

Hi Mits,

Thank you for your guidance as your replies to this thread is very helpful. I have found a solution in modifying the task description for the workflow with the solution below;


This is done by modifying the event "task-assign" with the code provided below.
Note that you also need to add "bpm_package" as a variable.


taskInstance.desciption = "updated document" + bpm_package.children[0].properties["cm:name"];