Updating Task#resources in BPMN 2.0 XML

In your current case I see a number of issues:

  • Invisible BPMN elements do not need to be wrapped in diagram elements
  • The partnerRole element is a bpmn:RootElement and has to be added to the Definitions#rootElements collection to be contained within the BPMN document

The following code snippet should do the job:

var partnerRole = bpmnFactory.create('bpmn:PartnerRole', { name: 'AppEnsemble', participantRef: [ participant ] });

// unwrap Participant -> Collaboration -> Definitions
var definitions = participant.$parent.$parent; 

// wire partnerRole with BPMN document (via Definitions)
definitions.get('rootElements').push(partnerRole);

Note that I do not use modeling.updateProperties(...) because definitions is not a diagram element. This is something we could support in the future. If you would like to make the assignment undoable, read this thread.

1 Like