Object added with event listener isn’t available until editing doc for second time

The document is not created when you enter edit mode. Click Cancel and you’ll see. The document is created when you click Save the first time. So the behavior you describe is normal considering that both events you are listening too are called after you click Save.

Read again my comment on Help customising Diagram.DiagramSheet - #4 by mflorea and you’ll see that you can add the object from the template, if it doesn’t exist already, and with the help of the “updateOrCreate” object policy it will be saved.

Hope this helps,
Marius