Calculate with Variables

Hello,

is there any way to calculate with Values in Camunda Modeler. Lets say i have two Process Variables:

“ageOfChild1” and “ageOfChild2”. Is it possible to add these Values (ageOfChild1 + ageOfChild2 = ageOfAllMyChildren) and safe ageOfAllMyChildren as a new Process Variable. Or maybe i need to write a new Java Class to calculate with those Values ?

Greetings
Feidex

There are a lot of ways of doing this but if you want you can do it as an expression.
assuming thingOne and thingTwo exist as variable. it will create a new variable called thingOneAndTwo. see below for implementation.

1 Like

Hi Niali,

thank you for your quick reply.

And how is the Expression if I want to calculate with Attributes of my Java Class?

Lets say I have the following Attributes in Java Class Company: (company is an Object)

company.Salary1, company.Salary2 and company.CumulatedSalary?

How can I calculate with them ?

Feidex

Depends - If you’re dealing with a java object it’s probably a lot easier to do the calculation in the java class itself and then just set the result as a process variable. The alternative would be to serialize the java object and then you could manipulated it using camunda spin..

Although the first option is the one i would go for.

Okay! Do I need JavaDelegate for this ?

Do you have an example Class? I´m not very professional Java-Developer ? :smiley:

Greetings
Feidex

My Advice would be to follow the Java Developer video tutorial. If you follow it along it should answer most of your questions: https://camunda.com/learn/videos/