Custom attributes

Can I add a custom attribute “camunda:candidateUsersReadOnly”, for example:

<bpmn:userTask id="Task_1eqdx5t" name="task_name" camunda:candidateUsersReadOnly="IC754VBA08D5UC93XE,IC754VBA08D5UC93ZC">

How should I get the value of this attribute?

One way to add custom attributes to activities is by using Extension Properties.

In the Camunda Modeler, you can add them via the Extensions tab in the properties panel on the right hand side when you select an activity in your model.

You can also add them manually to your model XML of course by adding the following to your activity:

      <bpmn:extensionElements>
        <camunda:properties>
          <camunda:property name="test" value="value" />
        </camunda:properties>
      </bpmn:extensionElements>

There are several topics on the forum about retrieving those extension properties from model elements via Model API like this one here:

Hope that helps.

Cheers,
Tobias

You can do this

ModelElementInstance modelElementInstance = bpmn.getModelElementById("Task_1eqdx5t");
FlowNode flowNode = (FlowNode) modelElementInstance;
String  candidateUsersReadOnly = flowNode.getAttributeValueNs("http://camunda.org/schema/1.0/bpmn", "candidateUsersReadOnly")