AnsweredAssumed Answered

How to properly declare, change and use workflow process variables?

Question asked by Aleksey Bykov on Feb 15, 2017
Latest reply on Feb 16, 2017 by Aleksey Bykov

Based on the example kindly provided by Mr. Potts, I've developed the system of the contracts approval.

 

Business process in BPMN notation is presented below.

 

By Activiti Eclipse BPMN 2.0 Designer:

 

 

The scheme of a running business process in Alfresco:

 

 

On my local computer installed:

 

Alfresco Share v5.2.d(r134641-b15, Aikau 1.0.101.3, 
Spring Surf 5.2.d, Spring WebScripts 6.13,
Freemarker 2.3.20-alfresco-patched,
Rhino 1.7R4-alfresco-patched,
Yui 2.9.0-alfresco-20141223)

Alfresco Community v5.2.0(r134428-b13) schema 10005

 

And everything works fine...

 

However, the problem occurs when I installed the system on the server, where:

 

Alfresco Share v5.2.c(r133673-b12, 
Aikau 1.0.99, Spring Surf 5.2.c,
Spring WebScripts 6.11,
Freemarker 2.3.20-alfresco-patched,
Rhino 1.7R4-alfresco-patched,
Yui 2.9.0-alfresco-20141223)

Alfresco Community v5.2.0(r133656-b12) schema 10005

 

In the process of approval, I get this error message:

 

org.activiti.engine.ActivitiException: Unknown property used in expression: ${scwf_approveCount < 2}

 

NB: Error appears only after processing by the next group (no matter first or second) - for example, if the contract approved / rejected by the first group, then the second group can't neither approve nor reject.

 

The portal ecmarchitect says that:

 

You may be wondering why this is a service task instead of a script task. In 5.0.d, the underlying JavaScript engine in Activiti switched from Rhino to Nashorn. This caused a problem related to setting execution variables. The work around is to use a service task.

 

And shows the example of how to initialize variables in this case:

 

<serviceTask id="scripttask1" name="Submit" activiti:class="org.alfresco.repo.workflow.activiti.script.AlfrescoScriptDelegate">
  <extensionElements>
    <activiti:field name="script">
      <activiti:string><![CDATA[execution.setVariable('scwf_approveCount', 0);
          execution.setVariable('scwf_tpApproved', false);]]>
</activiti:string>
    </activiti:field>
  </extensionElements>
</serviceTask>

 

I found several discussions about this, but none of the approach described in them did not help in my case:

 

Unknown property used in expression

ExceptionActiviti: unknown property used in expression

Advanced Workflow Tutorials

Property Not Defined

Property error on JavaScript variables

 

For example, I tried to initialize the variables by these ways:

 

...

<scriptTask id="scripttask1" name="Submit" scriptFormat="javascript" activiti:autoStoreVariables="true">    <script>var scwf_approveCount = 0; var scwf_tpApproved = false;</script></scriptTask>

...   
<scriptTask id="scripttask1" name="Submit" scriptFormat="javascript"><script><![CDATA[var scwf_approveCount = 0; var scwf_tpApproved =false;]]></script></scriptTask>

...

<scriptTask id="scripttask1" name="Submit" scriptFormat="javascript" activiti:autoStoreVariables="true">    <script>execution.setVariable('scwf_approveCount', 0); execution.setVariable('scwf_tpApproved', false);</script></scriptTask>

...

 

 

I think I need to reinstall application on the server for matching of the local installation.
Is there another way to solve this problem?

 


I would be very grateful for the information. Thanks to all.

 

---

 

Additional information: I installed exactly the same systems. On the server and on my local computer:

 

Alfresco Share v5.2.d (r134641-b15, Aikau 1.0.101.3, 
Spring Surf 5.2.d,
Spring WebScripts 6.13,
Freemarker 2.3.20-alfresco-patched,
Rhino 1.7R4-alfresco-patched,
Yui 2.9.0-alfresco-20141223)
Alfresco Community v5.2.0 (r134428-b13) schema 10005

 

 

But it's very strange - locally everything works fine but on the server I get the same error again:

 

org.activiti.engine.ActivitiException: Unknown property used in expression: ${scwf_approveCount < 2}

 

I compared the data in the diagram and in the underlying XML and they are the same.

Outcomes