Convert to Smart Object - how

Is there no way to create a smart object without going into BatchPlay?

I am just getting started with UXP (from ExtendScript) and simply want to do the equivalent of the right click Convert to Smart Object.

In ExtendScript I did this via ScriptListener, but hoped things had moved on a decade or two. Having read batchPlay is an advanced API, and we recommend trying to first use the DOM APIs before resorting to using batchPlay., I have been trying to absorb the API documentation and trying code like:

app.activeDocument.createLayer(constants.LayerKind.SMARTOBJECT ,{ name: "not descriptive name"});

But this still only create a new layer. Any clues? Or do I have to get into BatchPlay?

Yes. In the current state, the batchPlay is the only option.

Thank you for confirming.

I tried BatchPlay and quickly got the code finished, thanks to the Copy as Javascript menu in the Actions panel. It was a whole lot easier than implied by that comment in Adobe’s documentation.

This one is easy to do with a batchPlay. But if you would like to e.g. get all layers within single selected group then it wouldn’t be in favor of batchPlay.