How to create association

How can I add associations as shown in the Picture below?
By clicking on the connect Symbol via contextPad I want to be able
to choose one of those associations, so I guess I have to extend the
contextPadProvider. Could anyone explain how to do it?
Thanks in advance and kind regards
image

I found a Solution by customizing Ruleprovider. But when I move an object connected by bpmn:Association the dashed line will be removed. When I change the type to sequenceFlow it works properly. This might be an error of the toolkit?

What you’re trying to achieve doesn’t seem to be allowed by the BPMN 2.0 specification, that’s why the rules permit it.

If you update these rules we can not guarantee that will work since our tool should be following the specification at any time. Cf. design principles

1 Like

Could you elaborate on why you need this? What should that express?

I added a new Element based on the customElelements-Example called AssistanceSystem. Since that should look very similar to bpmn:Transaction, I actually add a bpmn:Transaction with new Properties I created in a json-file and a customRendering. This Element shall only be able to connect with Tasks and other AssistanceSystems over an association (dashed line without arrows). For last one I modified the ruleProvider by changing canConnect-method the type for bpmn:Transaction to bpmn:association. That first seem to work but when I move an Element, the dashed line disappears. I also checked the customShapes example by replacing custom:connection to bpmn:association in its CustomRules and the behaviour is the same. That means, even with an entirely new custom Element it has the same effect, therefore it shouldn’t matter that I actually use bpmn:Transactions Elements for my purpose.

The correct way to achieve this is to disallow connecting elements via bpmn:SequenceFlow if there is no other connection type, bpmn:Association is chosen (if allowed by rule).

I did like you said. So, I disallowed bpmn:Transactions to be connected via bpmn:SequenceFlow and added the type to bpmn:Association for it.
Unfortunately the assocations still disappear, when I move a connected element.
I really don’t understand the behaviour. I tried to archieve this by changing the
function: canConnect in BpmnRules.js. Hope, that someone can help.
Here is my Code:

function canConnect(source, target, connection) {

  if (nonExistingOrLabel(source) || nonExistingOrLabel(target)) {
    return null;
  }

  if (!is(connection, 'bpmn:DataAssociation') &&
		!is(target, 'bpmn:Transaction') &&
		!is(source, 'bpmn:Transaction')) {

    if (canConnectMessageFlow(source, target)) {
      return { type: 'bpmn:MessageFlow' };
    }

    if (canConnectSequenceFlow(source, target)) {
      return { type: 'bpmn:SequenceFlow' };
    }
  }

  var connectDataAssociation = canConnectDataAssociation(source, target);

  if (connectDataAssociation) {
    return connectDataAssociation;
  }

  if (isCompensationBoundary(source) && isForCompensation(target)) {
    return {
      type: 'bpmn:Association',
      associationDirection: 'One'
    };
  }

  if (canConnectAssociation(source, target) || isTransaction(source) || isTransaction(target)) {
    return {
      type: 'bpmn:Association'
    };
  }

  return false;
}

I found the reason. In ReplaceConnectionBehaviour.js the lines:

if (is(connection, 'bpmn:Association') && !bpmnRules.canConnectAssociation(source, target)) {
      remove = true;
    }

caused the error. So I simply had to modify the canConnectAssocation-method in BpmnRules.js
It works fine now, so this topic can be closed