Element registry not working on modeler

Hi, Here is my code for colouring an element in BpmnModeler.
The elementRegistry works fine, but elementRegistry.get does not…

The code :point_down:

    const elementRegistry = modeler.get("elementRegistry");
    console.log('elementRegistry',elementRegistry)

    const startEvent = elementRegistry.get('Activity_1iadx4f');
    console.log("startEvent", startEvent )

the element registry by chrome inspect
image

The error :point_down:
image

As you can see, the start event is undefined even when Id is correct.

why is this error occuring?

Sorry if the format or details of question are not upto the mark, if needed any extra details i will update.
Thank you

In which place do you try to get the element? Before or after the diagram import?

Chrome dev tools show that the elementRegistry changed after your console.log (via the i icon). A possible indication that you try to access the element before it was added.

image

1 Like

Yes solved.
I Used the async and await method to solve it.

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