How to use addAdornment?

I’ve tried to use the addAdornment function to programatically add an adornment to a node. This is the adornment template:

$(go.Adornment, 'Auto',
        {
            layerName: "Background",
            selectable: false,
            isInDocumentBounds: false,
            desiredSize: new go.Size(400, 400)
        },
        $(go.Shape, "Circle",
            {
                fill: $(go.Brush, "Radial", {0.0: "blue", 1.0: "white"}),
                stroke: null
            }),
        $(go.Placeholder)//, {alignment: go.Spot.Center, alignmentFocus: go.Spot.Center})
    );

However, I get an exception. As far as I can tell, the exception is caused by: $(go.Placeholder).
This is the exception: TypeError: Cannot read property ‘fb’ of null
When I remove the placeholder, no exception is thrown, but also no adornment is visible.

AddAdornment is called inside a transaction.

What am I doing wrong?

The most common usage for Part.addAdornment and Part.removeAdornment is in overrides of Tool.updateAdornments.

However, you can call those methods in other circumstances. For example, take a look at Buttons that show on Hover.

It isn’t clear to me what might be wrong in your app.

I found the bug, I didn’t set:

adornment.adornedObject = node;

Tnx walter!!
I hope I’m not overstepping any boundaries, and forgive me if I am, but maybe this is the kind of thing that should be mentioned in the docs.

That’s exactly the kind of feedback we need to improve GoJS. Thanks!

I’ve added a reminder to set Adornment.adornedObject in the documentation for Part.addAdornment for the next release.