Creating a process variable without DMN

Need quick hint on modelling a simple process.

Got a process Cawemo | Welcome . Requirement is that, when this is executed a variable named “result” should be created with values 0 (or) 1 based on below logic

That is
If age >= 16 then “result” should be “1”
else “result” should be “0”

I understand this can be done easily with a simple DMN. But if DMN is not the choice, how this can be achieved.

Thanks for taking time and looking into this.

Answering my own question.

Never mind, I totally missed that this can be achieved with Service task with expression implementation type.

But what would be the solution when using CMMN?
Inside CMMN i need to create new process variable. With DMN i can do it, but a bit complicated. Would like to have a bit more simple solution.

Thanks to friends in Camunda forum, solution in CMMN is:

  • instead of “execution.setVariable”, use “caseExecution.setVariable”.

        <cmmn:task id="Task_0n5nmop" name="SmallLoanSize">
          <cmmn:extensionElements>
            <camunda:caseExecutionListener event="start">
              <camunda:script scriptFormat="javascript"><![CDATA[var myjson=JSON.parse(json);myjson.approved=true;caseExecution.setVariable("json",JSON.stringify(myjson));]]></camunda:script>
            </camunda:caseExecutionListener>
          </cmmn:extensionElements>
        </cmmn:task>