Problem : Cannot read property isGeneric of undefined

Hi,
I’ve custom meta model

{
  "name": "Collaboration variables payload",
  "uri": "http://www.graphinfotec.com/schema/xml/variables",
  "prefix": "var",
  "xml": {
    "tagAlias": "lowerCase"
  },
  "types": [
    {
      "name": "variables",
      "superClass": [
        "Element"
      ],
      "properties": [
        {
          "name": "variableItems",
          "type": "variableItems",
          "isMany": true
        }
      ]
    },
    {
      "name": "variableItems",
      "superClass": [
        "variables"
      ],
      "properties": [
        {
          "name": "variable",
          "type": "variable",
          "isMany": true,
          "isGeneric": false
        }
      ]
    },
    {
      "name": "variable",
      "superClass": [
        "variableItems"
      ],
      "properties": [
        {
          "name": "id",
          "type": "Number"
        },
        {
          "name": "name",
          "type": "String"
        },
        {
          "name": "title",
          "type": "String"
        },
        {
          "name": "value",
          "type": "String"
        }
      ]
    }
  ],
  "emumerations": [],
  "associations": []
}

and successfully filled and everythings ok but when I want export as xml I get error

could not save bpmn xml TypeError: Cannot read property 'isGeneric' of undefined

please help me how to fix this problem

1 Like

Hi Hadi_Jami,

How do you use these meta tags, do you try catch some events then add new objects/attributes if yes, please share your code?

I have met this kind of error before because of approximate declare meta data tag and incorrect create object attributes

Can you provide code that reproduces this problem? This starter example makes it easy to test your model extension.

1 Like

It’s very simple and cool. for my project I can not use property panel and camunda providers, for this problem I create custom model with this config:

{
  "name": "Collaboration variables payload",
  "uri": "http://www.graphinfotec.com/schema/xml/variables",
  "prefix": "var",
  "xml": {
    "tagAlias": "lowerCase"
  },
  "types": [
    {
      "name": "ElementVariables",
      "superClass": [
        "Element"
      ],
      "properties": [
        {
          "name": "variables",
          "isMany": true,
          "type": "Variable"
        }
      ]
    },
    {
      "name": "Variable",
      "properties": [
        {
          "name": "id",
          "type": "String"
        },
        {
          "name": "name",
          "type": "String"
        },
        {
          "name": "title",
          "type": "String"
        },
        {
          "name": "value",
          "type": "String"
        }
      ]
    }
  ],
  "emumerations": [],
  "associations": []
}

and in code I used: [Complete code]

this.modeler = new BpmnJS({
  container: '#designer-canvas',
  keyboard: {
    bindTo: window
  },
  moddleExtensions: {
    var: {
      "name": "Collaboration variables payload",
      "uri": "http://www.graphinfotec.com/schema/xml/variables",
      "prefix": "var",
      "xml": {
        "tagAlias": "lowerCase"
      },
      "types": [{
          "name": "ElementVariables",
          "superClass": ["Element"],
          "properties": [{
            "name": "variables",
            "isMany": true,
            "type": "Variable"
          }]
        },
        {
          "name": "Variable",
          "properties": [{
              "name": "id",
              "type": "String"
            },
            {
              "name": "name",
              "type": "String"
            },
            {
              "name": "title",
              "type": "String"
            },
            {
              "name": "value",
              "type": "String"
            }
          ]
        }
      ],
      "emumerations": [],
      "associations": []
    }
  }
});

and in any element I used:

var ElementVariables = _moddle.create('var:ElementVariables');

_rootElement.businessObject.extensionElements = _moddle.create('bpmn:ExtensionElements');

_rootElement.businessObject.extensionElements.get('values').push(ElementVariables);

ElementVariables.variables = [];

$.each(result.data, (i, item) => {
  var _variable = _moddle.create('var:Variable', {
    id: `${item.Id}`,
    name: item.Name,
    title: item.Title,
    value: ''
  });
  ElementVariables.variables.push(_variable);
});

and worked successfully for me :wink:

I hope helped you (sorry for bad english)

again from previous post, thank you for your attention, I fixed my problem

Cool! Mind sharing your solution?

Hi @philippfromme,

Answer for @nguyenhoathuan is my solution :wink::wink: worked successfully and I can add more extension with this format.

solution