Custom-meta-model

I want to create custom-meta-model, but it doesn’t work. It can write to XML
image

But It can not read this custom model. when i read this xml

<jiuling:assignessSelector id="1626254803702" type="listByDeptCodes" variable="" value="dept" />

was ignored. And I don’t get any error or warnins

tips: I have configured the description file

Hi @mmx ,

In general:
did you follow along the bpmn-js model extension example? This should give you everything you need.

To your problem:
we need more details to help you. How do you read the xml, how to you load the model extension, … Please provide code snippets or even better a working example that we can use to re-produce the problem you encounter.

2 Likes

yeah. thanks
And I saw this example, but in my project, it’s a little different.

That’s about it

// init
import jiuling from './jiuling.json'
new BpmnModeler({
        container: this.$refs['bpmn-canvas'],
        keyboard: this.keyboard ? { bindTo: document } : null,
        additionalModules: {},
        moddleExtensions: { jiuling }
 })
// this is my description file
{
  "name": "JiuLing",
  "uri": "http://activiti.org/bpmn",
  "prefix": "jiuling",
  "xml": {
    "tagAlias": "lowerCase"
  },
  "types": [
    {
      "name": "Base",
      "superClass": [
        "Element"
      ],
      "meta": {
        "allowedIn": [
          "*"
        ]
      },
      "properties": [
        {
          "name": "id",
          "type": "String",
          "isAttr": true
        },
        {
          "name": "values",
          "type": "AssignessSelector",
          "isMany": true
        }
      ]
    },
    {
      "name": "AssignessSelector",
      "superClass": [
        "Element"
      ],
      "properties": [
        {
          "name": "id",
          "type": "String",
          "isAttr": true
        },
        {
          "name": "type",
          "type": "String",
          "isAttr": true
        },
        {
          "name": "name",
          "type": "String",
          "isAttr": true
        },
        {
          "name": "variable",
          "type": "String",
          "isAttr": true
        },
        {
          "name": "value",
          "type": "String",
          "isAttr": true
        }
      ]
    },
    {
      "name": "SkipDecider",
      "superClass": [
        "Element"
      ],
      "properties": [
        {
          "name": "value",
          "type": "Boolean",
          "isAttr": true
        },
        {
          "name": "type",
          "type": "String",
          "isAttr": true
        }
      ]
    },
    {
      "name": "Notify",
      "superClass": [
        "Element"
      ],
      "properties": [
        {
          "name": "type",
          "type": "String",
          "isAttr": true
        },
        {
          "name": "value",
          "type": "Boolean",
          "isAttr": true
        }
      ]
    }
  ]
}

And now I can create <jiuling:AssignessSelector />, it works

moddle.create('jiuling:AssignessSelector', {
        type: 'wechat',
        value: 'test'
 })

But when I get this xml(string) by ajax and import thought ‘importXML’ function, <jiuling:AssignessSelector /> is ignored, and I don’t get any error or warnings.
I don’t know if I made a mistake. I hope I can correct my mistake

I forgot to reply to you. My answer is on it

I hope you can help me solve this problem.

Thanks!

Thanks for the details.

Why do you define a “Base” element here?

   {
     "name": "Base",
     "superClass": [
       "Element"
     ],
     "meta": {
       "allowedIn": [
         "*"
       ]
     }
[...]

Let’s look at AssignessSelector. It extends “Element”.

{
     "name": "AssignessSelector",
     "superClass": [
       "Element"
     ],
     "properties": [
       {
         "name": "id",
         "type": "String",
         "isAttr": true
       },
       {
         "name": "type",
         "type": "String",
         "isAttr": true
       },
       {
         "name": "name",
         "type": "String",
         "isAttr": true
       },
       {
         "name": "variable",
         "type": "String",
         "isAttr": true
       },
       {
         "name": "value",
         "type": "String",
         "isAttr": true
       }
     ]
   }

This means it can extend “Element” for example like this:

    <bpmn2:task id="Task_1" name="MyTask">
      <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing>
      <bpmn2:extensionElements>
        <jiuling:AssignessSelector variable="abc"/>
      </bpmn2:extensionElements>
    </bpmn2:task>

You can easily access the custom element then like this:

const elementRegistry = bpmnModeler.get('elementRegistry');

const task = elementRegistry.get('Task_1');

console.log(task.businessObject.extensionElements.values[0]);

This will yield:
Screenshot_20210715_081558

Bottom-line: could you please more precise with the use-case you want to implement, what is your goal?

oh ! I found my mistake. It’s a very elementary problem. I’m so sorry

Thank you for your reply