cancel
Showing results for 
Search instead for 
Did you mean: 

multiple writable variables

jwrobel
Champ in-the-making
Champ in-the-making
So I was happily coding away when I ran into this funny error:

17:46:12,947 ERROR [org.jbpm.graph.def.GraphElement] action threw exception: AlfrescoJavaScript supports only one writable variable
org.alfresco.service.cmr.workflow.WorkflowException: AlfrescoJavaScript supports only one writable variable
‍‍‍‍

The culpret was:

<event type="process-start">
   <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
      <script>        
         <variable name="office_managers_group" access="read,write"/>
         <variable name="contracts_administrators_group" access="read,write"/>
         <variable name="accounts_receivable_group" access="read,write"/>
         <expression>
            office_managers_group = people.getGroup('GROUP_office managers');
            contracts_administrators_group = people.getGroup('GROUP_contracts administrators');
            accounts_receivable_group = people.getGroup('GROUP_accounts receivable');
         </expression>
      </script>
   </action>
</event>
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

The workaround is to create several actions in the same event each with only 1 variable:

<event type="process-start">
      <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
         <script>
            <expression>
               office_managers_group = people.getGroup('GROUP_office managers');
            </expression>
            <variable name="office_managers_group" access="write"/>
         </script>
      </action>
      <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
         <script>
            <expression>
               contracts_administrators_group = people.getGroup('GROUP_contracts administrators');
            </expression>
            <variable name="contracts_administrators_group" access="write"/>
         </script>
      </action>
      <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
         <script>
            <expression>
               accounts_receivable_group = people.getGroup('GROUP_accounts receivable');
            </expression>
            <variable name="accounts_receivable_group" access="write"/>
         </script>
      </action>
</event>
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

This was done on Alfresco Labs - v3.0.0 (c 1342)
1 REPLY 1

vinaxwater
Champ in-the-making
Champ in-the-making
I don't use tab <event type="process-start">. You can use as:

<start-state name="start">
    <task name="wf:startOfficialTask" swimlane="initiator"></task>
        <transition to="nodeSubmit" name="startLegal/Official">
            <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
                <script>
                    <variable name="wf_temp" access="write" />
                    <expression>wf_temp = 0;</expression>
                </script>
           </action>
        </transition>
</start-state>
‍‍‍‍‍‍‍‍‍‍‍‍‍

When You start workflow is parameter wf_temp with value 0 created. Can create mutiple parameter in this case.

Regards.