cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with variables during workflow execution

blackout
Champ in-the-making
Champ in-the-making
I encountered problems using some Alfresco defined variables during workflow execution.

I wanted to create some folders at run time, the best way I found to do it was using code like this:
Node createFolder(string name)
and this:
Node createNode(string name, string type)
and I noticed that companyhome, userhome and initiatorhome were not working, so I thought to use bpm_context, and even this time I had a null reference!

The specific part of code where I used it was:
   <swimlane name="reception">
      <assignment actor-id="admin"/>
   </swimlane>

   <start-state name="start">
      <task name="wf:startGoFlow" swimlane="reception"/>
      <transition name="" to="updatePipeline">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               var testFolder = companyhome.childByNamePath("Test Space");
               var prjFolder = testFolder.createFolder("Test Folder");
               prjFolder = prjFolder.childByNamePath("Test Folder");
               prjFolder.createFolder("Documents");
               prjFolder.createfolder("Random Folder");
            </script>
           </action>
        </transition>
   </start-state>

How can I manage this?

Another thing: can I add dinamically documents to the bpm_package? If yes, how?

Thanks again for your help!
1 REPLY 1

davidc
Star Contributor
Star Contributor
I noticed that companyhome, userhome and initiatorhome were not working

1.4 community does not support these variables.

1.4 enterprise, 2.0 preview and HEAD all do support them.

so I thought to use bpm_context, and even this time I had a null reference!

bpm_context (and other workflow instance variables - as listed in http://wiki.alfresco.com/wiki/WorkflowAdministration#Process_Data) are only available once the start task has been completed.  So, you can use the "node-leave" event on your start-state to create folders.

Another thing: can I add dinamically documents to the bpm_package? If yes, how?

Unfortunately not.  The Javascript API does not yet allow the addition of an existing node into a folder.  I'll raise a JIRA task - it's a common workflow request.  The call would be something like:

folder.addNode(node);