# Error when trying to associate components (task/annotation)

**URL:** <https://forum.bpmn.io/t/error-when-trying-to-associate-components-task-annotation/10931>\
**Category:** Users\
**Created:** [April 22, 2024, 12:58pm UTC](https://forum.bpmn.io/t/error-when-trying-to-associate-components-task-annotation/10931 "2024-04-22T12:58:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lgod](https://forum.bpmn.io/letter_avatar_proxy/v4/letter/l/b77776/32.png) [@lgod](https://forum.bpmn.io/u/lgod)\
**Post date:** [April 22, 2024, 12:58pm UTC](https://forum.bpmn.io/t/error-when-trying-to-associate-components-task-annotation/10931/1 "2024-04-22T12:58:33Z")

</div>

I’m trying to create an association between a task and an annotation, how to do it, I’m getting errors like:

> Error: no shape type specified  
> at ElementFactory.createElement (ElementFactory.js:168:13)  
> at ElementFactory.create (ElementFactory.js:129:15)  
> at ElementFactory.createConnection (ElementFactory.js:68:15)  
> at createConnectedAnnotation (CustomPalette.js:82:46)  
> at Object.click (CustomPalette.js:132:15)

Este é um trecho do codigo do meu componente Customizado:

```auto

export default class CustomPalette {
  constructor(bpmnFactory, create, elementFactory, palette, translate, modeling) {
    this.bpmnFactory = bpmnFactory;
    this.create = create;
    this.elementFactory = elementFactory;
    this.translate = translate;
    this.modeling = modeling;

    palette.registerProvider(this);
  }

  getPaletteEntries(element) {
    const {
      bpmnFactory,
      create,
      elementFactory,
      translate,
      modeling
    } = this;

    function getSelectedElementData() {
      const element = modeler._current.element; // Obtenha o elemento atualmente selecionado
      const elementData = {};

      // Exemplo: Acesse o nome e a descrição do elemento (pode variar dependendo das suas necessidades)
      elementData.name = element.businessObject.name;
      elementData.description = element.businessObject.documentation && element.businessObject.documentation[0].text;

      return elementData;
    }

    function createTask(suitabilityScore) {
      const businessObject = bpmnFactory.create('bpmn:Task');
      businessObject.suitable = suitabilityScore;
      const shape = elementFactory.createShape({
        type: 'bpmn:Task',
        businessObject: businessObject
      });

      return shape;
    }

    function createAnnotation(annotationText) {
      if (modeler) {
        const propertiesPanel = getSelectedElementData();
      }
      const businessObject = bpmnFactory.create('bpmn:TextAnnotation', {
        text: annotationText
      });
      const annotation = elementFactory.createShape({
        type: 'bpmn:TextAnnotation',
        businessObject: businessObject,
        y: 80,
        width: 120,
        height: 70,
      });
      return annotation;
    }

    function createConnectedAnnotation(event, annotationText, task) {
      const annotation = createAnnotation(annotationText);
      create.start(event, [task, annotation]);
    
      // Create connection manually between task and annotation
      const connection = bpmnFactory.create('bpmn:Association', {
        source: task.businessObject,
        target: annotation.businessObject,
      });
    
      // Add the connection to the modeler
      const connectionShape = elementFactory.createConnection(connection);
      modeling.createConnection(connectionShape);
    }
    
    
    

    return function (entries) {

      // delete entries['tool-separator'];
      delete entries['space-tool'];
      delete entries['lasso-tool'];
      // delete entries['global-connect-tool'];
      delete entries['create.task'];
      delete entries['create.subprocess-expanded'];
      delete entries['create.start-event'];
      delete entries['create.data-object'];
      delete entries['create.data-store'];
      delete entries['create.end-event'];
      delete entries['create.exclusive-gateway'];
      delete entries['create.group'];
      delete entries['create.intermediate-event'];
      delete entries['create.participant-expanded'];
      delete entries['reate.intermediate-event'];
      delete entries['reate.intermediate-event'];
      delete entries['reate.intermediate-event'];

      // Add remaining entries to paletteEntries
      const paletteEntries = {
        ...entries, // Copy existing entries
        'create.low-task': {
          group: 'activity',
          title: translate('Cria uma Captação'),
          imageUrl: Captacao.dataURL,
          action: {
            dragstart: function (event) {
              const task = createTask(SUITABILITY_SCORE_LOW);
              const annotation = createAnnotation('Informe a descrição do componente');
              task.businessObject.documentation = [annotation.businessObject];
              create.start(event, [task, annotation]);

            },
            click: function (event) {
               const task = createTask(SUITABILITY_SCORE_LOW);
               /*
              const annotation = createAnnotation('Informe a descrição do componente');             
              task.businessObject.documentation = [annotation.businessObject];
              create.start(event, [task, annotation]); */
              createConnectedAnnotation(event,'Informe a descrição do componente',task);
            }
          }
        },

```

Thanks

---

<div class="post-metadata">

**Author:** ![Martin](https://forum.bpmn.io/letter_avatar_proxy/v4/letter/m/73ab20/32.png) [@Martin](https://forum.bpmn.io/u/Martin)\
**Post date:** [April 30, 2024, 12:51pm UTC](https://forum.bpmn.io/t/error-when-trying-to-associate-components-task-annotation/10931/2 "2024-04-30T12:51:58Z")

</div>

Please share a running / prototypical example that clearly shows what you’re trying to achieve, what is working and what is not.

Use our existing [starter projects](https://github.com/bpmn-io/bpmn-js-examples/tree/master/starter) to quickly hack it or share your existing, partial solution on GitHub or via a [CodeSandbox](https://codesandbox.io/s/bpmn-js-starter-m3kex?file=/src/index.js). Provide the necessary pointers that allow us to quickly understand where you got stuck.

This way we may be able to help you in a constructive manner.

Thanks ❤

---

<div class="post-metadata">

**Author:** ![barmac](https://forum.bpmn.io/user_avatar/forum.bpmn.io/barmac/32/974_2.png) [@barmac](https://forum.bpmn.io/u/barmac)\
**Post date:** [July 9, 2025, 10:10am UTC](https://forum.bpmn.io/t/error-when-trying-to-associate-components-task-annotation/10931/3 "2025-07-09T10:10:43Z")

</div>

Closed on July 9, 2025, 10:10am UTC

Closing old topics.
