Calculator

Hello Camunda world
i’m new in camunda and i want to create a calculator that add or multiply 2 numbers depends on user choice
i have to use a form to fill the v1 and v2 and operator [sum / multiply],without using any external code!

i’ve done something like this but it not working
Screen Shot 2020-07-12 at 13.32.26|690x367

@hanane92, instead of image, you can upload the bpmn file itself. It’s hard to debug the issue with image file. You can find the upload options in the editor.

image

this is the file @aravindhrs
thank you !

process2.bpmn (7.7 KB)

@hanane92, the expression was not provided properly. Refer the docs for Usage of Expression Language.

<bpmn:userTask id="id1" name="choose valueA and valueB and operation" camunda:assignee="fillform">
      <bpmn:extensionElements>
        <camunda:formData>
          <camunda:formField id="valueA" label="ValueA" type="long" />
          <camunda:formField id="valueB" label="ValueB" type="long" />
          <camunda:formField id="operation" label="Operation" type="string">
            <camunda:properties>
              <camunda:property id="sum" value="+" />
              <camunda:property id="multiply" value="*" />
            </camunda:properties>
          </camunda:formField>
        </camunda:formData>
      </bpmn:extensionElements>
      <bpmn:incoming>SequenceFlow1</bpmn:incoming>
      <bpmn:outgoing>Flow_0v420pn</bpmn:outgoing>
    </bpmn:userTask>

Sequence flow which has condition should be expressed as:

#{operation == '*'}

#{operation == '+'}

Expression configured in both service task is also completely wrong one.

It should be like:

${valueA + valueB} //sum service task expression

${valueA * valueB} //multiply service task expression


Configured camunda:asyncBefore="true" for the gateway to save the form variables.

<bpmn:exclusiveGateway id="Gateway_0t4lq9b" name="Operation?" camunda:asyncBefore="true">
      <bpmn:incoming>Flow_0v420pn</bpmn:incoming>
      <bpmn:outgoing>sumid</bpmn:outgoing>
      <bpmn:outgoing>multiplyid</bpmn:outgoing>
    </bpmn:exclusiveGateway>

I have modified your bpmn file. Deploy the below bpmn file and try:

Deploy this: process2 (1).bpmn (7.8 KB)

1 Like

thank you @aravindhrs it’s working fine now :slightly_smiling_face:

How should I do if I want to work on 3 or more numbers?