cancel
Showing results for 
Search instead for 
Did you mean: 

bpm_package is null in adv. workflow

kbootz
Champ in-the-making
Champ in-the-making
I'm trying to start an advanced workflow and set corresponding content model values based on user initialization parameters. I'm debugging the AlfrescoJavaScript class and when it tries to read the bpm_package variable I either get an undefined value error OR the value of bpm_package is null.

What is the proper(Javascript) way to access the underlying workflow content in Alfresco Community 3.2? I've attached the start task below, if more information is needed please let me know.

Thanks

   <start-state name="start">
      <task name="wf:startTask" swimlane="initiator"/>
      <event type="task-create">
        <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
          <script>
            <variable name="wf_FileName" access="read" />
            <expression>
            bpm_package.children[0].properties["doc.filename"] = wf_FileName;

           </expression>
         </script>
        </action>     
     </event>
     <transition name="" to="testContinuation"></transition>
   </start-state>
3 REPLIES 3

sethatrothbury
Champ in-the-making
Champ in-the-making
You have to access the bpm_package as a variable as well:


<start-state name="start">
<task name="wf:startTask" swimlane="initiator"/>
<event type="task-create">
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
<variable name="wf_FileName" access="read" />
<variable name="bpm_package" access="read,write" />
<expression>
bpm_package.children[0].properties["doc.filename"] = wf_FileName;

</expression>
</script>
</action>
</event>
<transition name="" to="testContinuation"></transition>
</start-state>

And wouldn't it be something like: bpm_package.children[0].properties.name = wf_FileName;  ?

kbootz
Champ in-the-making
Champ in-the-making
I neglected to state that I'm using the <event process-start …/> to set variable references. I'm thinking that perhaps I don't have access to bpm_package until after the workflow is started so I'm going to transition to a node and try to access there instead. I'm going to test that tomorrow -

Thanks for the feedback  Smiley Very Happy

kbootz
Champ in-the-making
Champ in-the-making
Yes…the bpm_package(content) is not available until after the workflow has been started. This is stated in one statement in the WorkflowAdministration wiki, buried in the Process Data section - "And the following Process variables are also available once the Start Task has been completed:"…