cancel
Showing results for 
Search instead for 
Did you mean: 

process variable vs. condition expression

larsson7
Champ in-the-making
Champ in-the-making
Hello all,

ich have a question about sequence flows and process variables. I have a process with a script task just after the start event. In the script task i define the process variable outputTransition that can get the value "approved" or "denied". After the script task, an exclusive gateway splits the process. And now i want to discribe the two sequence flows out of the gateway. If the process variable is "approved" it the process should go right if it is "denied" left.

But i get the following error:


Packages.com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil.updateStatus(Packages.com.liferay.portal.kernel.workflow.WorkflowConstants.toStatus(outputTransition), workflowContext);
06:58:38,253 ERROR [http-bio-8080-exec-3][render_portlet_jsp:154] org.activiti.engine.ActivitiException: Unknown property used in expression
   at org.activiti.engine.impl.el.JuelExpression.getValue(JuelExpression.java:55)
   at org.activiti.engine.impl.el.UelExpressionCondition.evaluate(UelExpressionCondition.java:37)
   at org.activiti.engine.impl.bpmn.behavior.ExclusiveGatewayActivityBehavior.leave(ExclusiveGatewayActivityBehavior.java:63)
   at org.activiti.engine.impl.bpmn.behavior.FlowNodeActivityBehavior.execute(FlowNodeActivityBehavior.java:36)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:44)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:80)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:546)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:541)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerStart.eventNotificationsCompleted(AtomicOperationTransitionNotifyListenerStart.java:52)
   at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:56)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:80)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:546)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:541)
   at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:49)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:80)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:546)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:541)
   at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionCreateScope.execute(AtomicOperationTransitionCreateScope.java:49)
   at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:80)
   at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperationSync(ExecutionEntity.java:546)
Caused by: org.activiti.engine.impl.javax.el.PropertyNotFoundException: Cannot resolve identifier 'outputTransition'

Can i use process variables in a flow expression and how? Can i declare a property in a script task so i can use it in a flow expression?

Can someone please help?!

Thanks all 🙂

Best regards, Philipp
11 REPLIES 11

frederikherema1
Star Contributor
Star Contributor
How do you set the variable in your script task? You can always use the "execution" object to set variables, or the "activiti:resultVariable" on the script-task:


<script>
    def scriptVar = "test123"
    execution.setVariable("myVar", scriptVar)
</script>

larsson7
Champ in-the-making
Champ in-the-making
My script task looks like that:


user = Packages.com.liferay.portal.service.UserLocalServiceUtil.fetchUser(10402);
roles = user.getRoleIds();
outputTransition = "denied";
for (i = 0; i < roles.length; i++) {
if (roles[i] == 15) {
  outputTransition = "approved";
break;
}
}
Packages.com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil.updateStatus(Packages.com.liferay.portal.kernel.workflow.WorkflowConstants.toStatus(outputTransition), workflowContext);

It works when i just check the variable outputTransition but when i want to use the variable later in the workflow it doesn´t..

Best regards, Philipp

frederikherema1
Star Contributor
Star Contributor
Use this after the for-loop:

execution.setVariable("outputTransition", outputTransition)

larsson7
Champ in-the-making
Champ in-the-making
Thanks frederikheremans,

but it doesn´t help..
Do i have to import another class or something to get it work?
I just create a script task and wrote the code above into main Config of the Script Task.
So when i try like you said, i get the following error:


Caused by: com.liferay.portal.kernel.scripting.ScriptingException: ReferenceError: "execution" is not defined.

I use eclipse and Liferay 6.1.

Thanks!

frederikherema1
Star Contributor
Star Contributor
What environment are you running in? Activiti inside life ray?

larsson7
Champ in-the-making
Champ in-the-making
I use the activiti pluin for liferay. Both with the newest versions.
So Activiti is integrated in liferay.
And i want to use activiti to model different workflows for example to create web content or something.

In my workflows i want add some code in javascript like above. To make it work in Liferay i have to change the scriptformat from javascript to LiferayJavaScript.

But there is one problem that i don´t see yet. For example the execution.setVariable().

So when i use the exmaple above in Liferay with scriptformat "javascript" i get the following error:

[http-bio-8080-exec-3][render_portlet_jsp:154] org.activiti.engine.ActivitiException: problem evaluating script: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "workflowContext" is not defined. (<Unknown source>#17) in <Unknown source> at line number 17

And when i use it with scriptformat "LiferayJavaScript" i get this:

com.liferay.portal.kernel.scripting.ScriptingException: ReferenceError: "execution" is not defined. (script#10)

Greetings and thanks!

frederikherema1
Star Contributor
Star Contributor
I'm not aware how the Liferay-plugin is hooked in. All I know is that activiti exposes the "execution" to all scripts in script-task, using the default JSR-223 ScriptBindings. It's up to the JS-engine to use this and seems like liferayJavascript doesn't expose this. Is the WorkflowContext also LiferaySpecific? Maybe it exposes a way to set variables on an execution?

larsson7
Champ in-the-making
Champ in-the-making
Yes WorkflowContext is also Liferay specific.
So when i understand you right, execution.setVariable is not supported in Liferay?! Is there any chance to get more information about activiti / Liferay integration?! It is very difficult to get the right information about this topic.

Best Regards, Philipp

frederikherema1
Star Contributor
Star Contributor
There are a couple of wiki-pages on http://www.emforge.net/web/activiti-liferay/wiki/-/wiki/Main/BPMN+2.0+for+Liferay+with+using+Activit.... I suggest checking out the sources for this to see how the nuts and bolts fit together…

The project not maintained by the Activiti core-team. Perhaps try to contact the project owner?