Skip to content
ralphhanna edited this page Jul 20, 2020 · 4 revisions

Table of Contents

Instance Data

Instance Data can be manipulated in several ways:

As Input to Engine calls

    const input={ model: 'Thunderbird', needsRepairs: false, needsCleaning: false };
    response = await engine.invoke({items: { id: itemId } }, input );

Expressions

keeping in mind that the bpmn definition defines conditional flow as such:
    <bpmn:sequenceFlow id="flow_gw1_clean" sourceRef="gateway_1" targetRef="task_clean">
      <bpmn:conditionExpression xsi:type="bpmn:tExpression"><![CDATA[
      (this.needsCleaning=="Yes")
      ]]></bpmn:conditionExpression>
    </bpmn:sequenceFlow>

Part of Script and Service Task

    <bpmn2:scriptTask id="task_reminder" name="Issue Reminder">
      <bpmn2:incoming>SequenceFlow_1h10gv4</bpmn2:incoming>
      <bpmn2:outgoing>SequenceFlow_0cokf0m</bpmn2:outgoing>
      <bpmn2:script><![CDATA[
            let data = this.token.data;
            console.log("sending a reminder scirpt");
            console.log(data);
            
            if (typeof data.reminderCounter === 'undefined') {
              data['reminderCounter']=0;
            }            
            
            data['reminderCounter']=data['reminderCounter']+1;
            this.token.log('testing from the inside: ');
      ]]></bpmn2:script>
    </bpmn2:scriptTask>

AppDelegate

Similar to Script and Service AppDelegate can manupilate Instance data, however AppDelegate are stateless.

Script Extensions

Script Extensions are supported in release 1.1 and later, allowing you to add a script to any node.

In this example we are adding a script to bpmn:startEvent

    <bpmn:startEvent id="StartEvent_1ohx91b">
      <bpmn:extensionElements>
        <camunda:script event="start"><![CDATA[
        console.log("This is the start event");
          this.applyInput({records:[1,2,3]});
          console.log(this.data);
          console.log("This is the start event");]]></camunda:script>
      </bpmn:extensionElements>
      <bpmn:outgoing>Flow_18xinq3</bpmn:outgoing>
    </bpmn:startEvent>
    

Data Scope

By Default all data elements belong to the root such as the case here

Image description

However, for SubProcess and Loop elements a seperate scope

Image description Image description

Query on Data

For Details on Query see Data Query

Input-Output Data

Clone this wiki locally