How to get all the signal components already defined

Hello,

I can’t find the way to get all the Signal components defined.

I tried to get the signal components:

var elements = elementRegistry.filter(function(element) {
  return is(element, 'bpmn:Signal');
});
```
Something is wrong because I inspected the elementRegistry but except the signal components, all are showed.

My bpmn json file is this:

```
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn">
  <bpmn:process id="Process_1" isExecutable="false">
    <bpmn:intermediateThrowEvent id="IntermediateThrowEvent_1cv6vqj">
      <bpmn:signalEventDefinition signalRef="Signal_0a19j3s" />
    </bpmn:intermediateThrowEvent>
  </bpmn:process>
  <bpmn:signal id="Signal_06yamxn" name="aaa" />
  <bpmn:signal id="Signal_0gkq9ht" name="bbb" />
  <bpmn:signal id="Signal_0og5kc1" name="ccc" />
  <bpmn:signal id="Signal_1lo07vs" name="ddd" />
  <bpmn:signal id="Signal_1cqhfhw" name="eee" />
  <bpmn:signal id="Signal_0a19j3s" name="fff" />
  <bpmn:signal id="Signal_0c8u6ci" name="ggg" />
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
      <bpmndi:BPMNShape id="IntermediateThrowEvent_1cv6vqj_di" bpmnElement="IntermediateThrowEvent_1cv6vqj">
        <dc:Bounds x="416" y="207" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="389" y="243" width="90" height="20" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>
```

Hello @rbatllet,

You can get the Signal elements with the code below:

var is = require('bpmn-js/lib/util/ModelUtil').is;
var root = elementRegistry.getRootElement(),
    definitions = root.businessObject.parent;

var signals = definitions.rootElements.filter(function(element) {
  return is(element, 'bpmn:Signal');
});

The reason it didn’t work for you is that the elementRegistry only has knowledge of graphical elements.

For what purpose do you need to grab the Signal definitions ? Would be easier to help you solve your issue with this knowledge.

Cheers,
Ricardo

How do you define the elementRegistry?

If I do this, it does not have any function attached to this json:

var elementRegistry = viewer.get(‘elementRegistry’);

{
  _elements: {
          Process_1: {...},
          StartEvent_1: {...},
          StartEvent_1_label: {....}
   }
}

I need a list of all the Signal event to let the user select which of them he want to assign to the
intermediateThrowEvent signalEventDefinition.signalRef property.

I think something is wrorg in your code. To get the definitions I’ve done this:

var root = renderer.get('canvas').getRootElement();
var definitions = root.businessObject.$parent;

@rbatllet, yes! you always need to use renderer.get('someService') to have access to the provided services.

And yes, I apologize for that mistake, the method .getRootElement() belongs indeed to the Canvas module.

Cheers,
Ricardo

@ricardomatias, Thank you very much for all the help and support given. I am very grateful !