cancel
Showing results for 
Search instead for 
Did you mean: 

Script variables through the whole workflow

blackout
Champ in-the-making
Champ in-the-making
Good day everyone,

I'm developing an extension of Alfresco to perform reports about workflows states, task performed and so on…
The idea is to put in a db table a record about the process (or task) instance with start date, due date, end date, reference to user and group who started it and few more informations. When I put the information in the db, I get back the id of the record in the table so that I can use it to retrive informations necessary for all the needed updates.

The process definition should be something like this:
<?xml version="1.0" encoding="UTF-8"?>

<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="wf:gopooledprocessdefinition">
   
…swimlanes definition…
   
   <start-state name="start">
      <task name="wf:startGoFlow" swimlane="initiator">
         <event type="task-end">
            <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
               <script>
                  …script…
                  var processInstanceId = edareport.addProcessInstance("2007-11-09 15:30:00",
                                                      "wf:gopooledprocessdefinition",
                                                      taskInstance.actorId,
                                                      "GROUP_sales");
               </script>
            </action>
         </event>
      </task>
      <transition name="" to="assignCustomerProjectNames" />
   </start-state>
   
   <task-node name="assignCustomerProjectNames">
      <task name="wf:assignCustomerProjectNamesTask" swimlane="initiator">
         <event type="task-assign">
            <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
               <script>
                  var taskInstanceId = edareport.addTaskInstance("2007-11-09 15:30:00",
                                                      "wf:assignCustomerProjectNamesTask",
                                                      initiator.properties.name,
                                                      "GROUP_sales",
                                                      processInstanceId);
                  edareport.setTaskInstanceAssignment(taskInstanceId, taskInstance.actorId, "GROUP_sales");
               </script>
            </action>
         </event>
         <event type="task-end">
            <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
               <script>
                  edareport.setTaskInstanceEnd(taskInstanceId);
               </script>
            </action>
         </event>
      </task>
      <transition name="" to="updatePipeline">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               …script…
            </script>
           </action>
      </transition>
   </task-node>

…other nodes/states…
   
   <end-state name="end" />
   
</process-definition>
As you probably noticed, I make calls to a custom defined bean, that puts/gets things from the db. What I really need is to move process variables from a task to another, like the processInstanceId variable. How can I do it?
Also, is there a way to get the group of a specified user (like the one I hand-put in the addProcessInstance method)?
1 REPLY 1

davidc
Star Contributor
Star Contributor
You might want to investigate:

1) Alfresco Auditing http://wiki.alfresco.com/wiki/Audit on the Workflow Service
2) JBoss jBPM logging