@bpmn-io/extract-process-variables

A util for bpmn-js to extract Camunda BPM process variables from a BPMN 2.0 diagram.

Usage no npm install needed!

<script type="module">
  import bpmnIoExtractProcessVariables from 'https://cdn.skypack.dev/@bpmn-io/extract-process-variables';
</script>

README

extract-process-variables

CI

An util for bpmn-js to extract Camunda BPM process variables from a BPMN 2.0 diagram.

Installation

$ npm i --save @bpmn-io/extract-process-variables

Usage

Given this example diagram

import {
  getProcessVariables,
  getVariablesForScope,
} from '@bpmn-io/extract-process-variables';

const canvas = modeler.get('canvas');

const rootElement = canvas.getRootElement();

const allVariables = getProcessVariables(rootElement.businessObject);
/* 
  [
    {
      "name": "variable1",
      "origin": [ "Task_1" ],
      "scope": "Process_1"
    },
    {
      "name": "variable2",
      "origin": [ "Task_1" ],
      "scope": "Process_1"
    },
    {
      "name": "variable3",
      "origin": [ "Task_2" ],
      "scope": "SubProcess_1"
    }
  ]
*/

const scopeVariables = getVariablesForScope('Process_1', rootElement.businessObject);
/* 
  [
    {
      "name": "variable1",
      "origin": [ "Task_1" ],
      "scope": "Process_1"
    },
    {
      "name": "variable2",
      "origin": [ "Task_1" ],
      "scope": "Process_1"
    }
  ]
*/

Note that origin and scope retrieves the full moddle element. The example outputs are reduced due to better readibility.

Note that camunda-bpmn-moddle descriptors have to be installed.

Properties support

We are currently extracting process variables from the following diagram properties

  • camunda:formField
  • camunda:outputParameter
  • camunda:out
  • camunda:resultVariable
  • camunda:errorCodeVariable
  • camunda:errorMessageVariable
  • camunda:escalationCodeVariable

See also

License

MIT