Add element template

I follow this topic to add element template, but it’s not work. can you help me?

bpmnModeler = new BpmnModeler({
    container: "#js-canvas",
    propertiesPanel: {
      parent: "#js-properties-panel",
    },
    additionalModules: [
      BpmnPropertiesPanelModule,
      BpmnPropertiesProviderModule,
      CamundaPlatformPropertiesProviderModule,
      camundaPlatformBehaviors,
      magicPropertiesProviderModule,
    ],
    moddleExtensions: {
      camunda: camundaModdleDescriptors,
      magic: magicModdleDescriptor,
    },
    elementTemplates: [
      {
        $schema:
          "https://unpkg.com/@camunda/element-templates-json-schema/resources/schema.json",
        name: "Mail Task",
        id: "com.camunda.example.MailTask",
        appliesTo: ["bpmn:ServiceTask"],
        properties: [
          {
            label: "Implementation Type",
            type: "String",
            value: "com.mycompany.MailTaskImpl",
            editable: false,
            binding: {
              type: "property",
              name: "camunda:class",
            },
          },
          {
            label: "Sender",
            type: "String",
            binding: {
              type: "camunda:inputParameter",
              name: "sender",
            },
            constraints: {
              notEmpty: true,
            },
          },
          {
            label: "Receivers",
            type: "String",
            binding: {
              type: "camunda:inputParameter",
              name: "receivers",
            },
            constraints: {
              notEmpty: true,
            },
          },
          {
            label: "Template",
            description:
              "By the way, you can use freemarker templates ${...} here",
            value: "Hello ${firstName}!",
            type: "Text",
            binding: {
              type: "camunda:inputParameter",
              name: "messageBody",
              scriptFormat: "freemarker",
            },
            constraints: {
              notEmpty: true,
            },
          },
          {
            label: "Result Status",
            description:
              "The process variable to which to assign the send result to",
            type: "String",
            value: "mailSendResult",
            binding: {
              type: "camunda:outputParameter",
              source: "${ resultStatus }",
            },
          },
          {
            label: "Async before?",
            type: "Boolean",
            binding: {
              type: "property",
              name: "camunda:asyncBefore",
            },
          },
        ],
      },
    ],
  });
  bpmnModeler.on("elementTemplates.errors", function (event) {
    console.log("template load errors", event.errors);
  });
  bpmnModeler.createDiagram();

I think you forgot to add the element templates feature: GitHub - bpmn-io/bpmn-js-element-templates: The element template extension for bpmn-js Try that and see whether it works.

Thank you!
I tried to npm install bpmn-js-element-templates, and add to additionalModules, the Template tab has been displayed, but when i click select, it’s nothing happen. what i did wrong?
图片

I added @bpmn-io/element-template-chooser, it;s working fine. Thank you again!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.