cancel
Showing results for 
Search instead for 
Did you mean: 

Using Math. functions

dranakan
Champ on-the-rise
Champ on-the-rise
Hello,

I would to use the absolute value (Math.abs) in my worklow. I have written like this :


<sequenceFlow id="flow9" name="" sourceRef="exclusivegateway3" targetRef="modifyReviewBoss1">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${sgfwf_approveRejectOutcome == 'Approve' && sgfwf_amount  > Math.abs(sgfwf_condition1) } ]]></conditionExpression>
    </sequenceFlow>

But I get this :

 2012-02-27 07:57:28,551  DEBUG [repo.jscript.ScriptLogger] [http-8080-22] org.activiti.engine.ActivitiException: Unknown property used in expression

How can I use Math.X functions ?

Thank you.

(post on activiti forum : http://forums.activiti.org/en/viewtopic.php?f=4&t=3539)
1 REPLY 1

dranakan
Champ on-the-rise
Champ on-the-rise
Thank you Lukasz for the response.

1. Create a java class as a wrapper for functions from Math class, for example:
package ch.custom.workflowUtils;

public class MathUtils {
   
    public int abs(int a) {
        return Math.abs(a);
    }

}
2. Register this class as a Spring bean, for example:
<bean id="mathUtils" class="ch.custom.workflowUtils.MathUtils" />

3. Add mathUtils bean to activitiBeanRegistry, for example:
<util:map id="activitiBeanRegistry" map-class="java.util.HashMap">
   <entry key="services" value-ref="ServiceRegistry" />
   <entry key="mathUtils" value-ref="mathUtils" />
</util:map>

4. Use mathUtils bean in expression, for example:
<conditionExpression xsi:type="tFormalExpression">${wf_actualPercent >= mathUtils.abs(1)}</conditionExpression>