AnsweredAssumed Answered

Share, BPM Package, Copy, etc.

Question asked by varsenault on Dec 25, 2012
Latest reply on May 22, 2013 by nalaka
Hi,

I'm trying to migrate a JBPM workflow from 3.2r to 4.2c (both on Ubuntu 12.10).

The workflow definition now needs to be adapted from a version that used to be started on spaces/directories of the repository in the Alfresco Explorer UI. We now want to use Share and there is no built-in way of starting a workflow on a space/directory. So we must work with adding all the children files from the space manually in the workflow start "task" UI". Then in the transition from that task, we want all the files in the BPM package to be copied to a "working space". And replace the references in the BPM package with references to the copied files.

My problem is that the two last loops (while, for) don't get executed. I get a new space created, but nothing is in it. And the BPM package still contains the references to the "template" documents that were supposed to get copied in the working space.

And, I'm unable to make use of the javascript logger due to a bug in Share (share won't start if the Javascript debugger/logger is enabled in the log4j configuration).

The last executed code seems to be the "createFolder" call. Please refer to code below. Thanks for your help!

Regards,

Vincent

<transition name="normal" to="Capture" >  
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <variable name="girproxyvoting2_companyName" access="read"/>
               <variable name="girproxyvoting2_meetingDate" access="read"/>
               <variable name="bpm_package" access="read,write" />
               <expression>
                  executionContext.setVariable("coordinator", person.properties.email.toString());
                  var coordinatorName = person.properties.firstName.toString() + " " + person.properties.lastName.toString();
                  executionContext.setVariable("coordinatorName",coordinatorName);
                  var monthString = new String((girproxyvoting2_meetingDate.getMonth() + 1));

                  if(girproxyvoting2_meetingDate.getMonth() &lt; 9) monthString = '-0' + monthString;
                  else monthString = '-' + monthString;

                  var spaceName = girproxyvoting2_companyName + " (" + (girproxyvoting2_meetingDate.getYear() + 1900) + monthString + "-" + girproxyvoting2_meetingDate.getDate() + ")";
                  var parentNode = companyhome.childByNamePath("GDV/Open");
                  var workingCopySpace = parentNode.createFolder(spaceName);


                  // Copy
                  while(bpm_package.children.length &gt; 0) {
                     var document = bpm_package.children[0];
                     document.copy(workingCopySpace);
                     document.remove();
                  }
                  // Add copied files to BPM package
                  for(var i = 0; i &lt; workingCopySpace.children.length; i++) {
                     bpm_package.addNode(workingCopySpace.children[i]);
                  }
                   </expression>
                 </script>
         </action>

Outcomes