Cycle through elements and delete if extension property

Hi bpmn.io community,

thank you very much for the great help last time. So far i am making good progress with my project.

Now i want to do the following:

  1. Cycle through all elements used in the diagramm
  2. check if the current element has the extended property “deleteme” and if it is “1”
  3. if both are true delete the element

So the goal is, that at the end of the procedure all elements that have the “deleteme” property equal to “1” are removed.

So far i have found the following code segments form the forum:


From what i understood it is best to work with the elementRegistry as it has a ForEach Function. But i could get it to work. Most likely because i am new to Javascript.

Would be very nice if someone could give me some tipps.

Best Regards

Hi everyone,

i made some progress and figured out the following:


  function deleteProcess2() {
  openDiagram(lastDiagramXML);    

//Get elements from elementRegistry  
var elementRegistry = bpmnModeler.get('elementRegistry');
var elements = elementRegistry.getAll();

//cycle through Elements
elements.forEach(function(element) {

//Here i still have Problems, the alert windows shows an object but how can i get the Value of Property "Eval"?
    var extras =  element.businessObject.extensionElements.ExtensionElementsHelper.get('eval');
    window.alert (extras);

`    //if value of property is more than 0 then delete it`
    if (extras>0){
        elementRegistry.remove(element);
    }
});
}

Would be nice if someone could give me an example on how to obtain that value correctly.

Thank you very much.

Best regards
BPMN4WIN

Hi everyone,

i figured out how the extension properties work. Thread can be closed.

Thx to those sending me messages