Weird behaviour of batchplay command "applyLocking" on groups and artboards

Here’s the code I got from Alchemist:

const batchPlay = require("photoshop").action.batchPlay;

const result = await batchPlay(
      _obj: "applyLocking",
      _target: [
            _ref: "layer",
            _enum: "ordinal",
            _value: "targetEnum"
      layerLocking: {
         _obj: "layerLocking",
         protectAll: true
      _options: {}

When the command is used on groups or artboards, it doesn’t simulate the normal behaviour as when I use the mouse to click the “lock all” button. Just wondering if there’s any simple fix to make it behave like the “lock all” button.

Maybe I’m misunderstanding something, but are you trying to unlock all layers with the lock command?

protectAll: true

What if you change to false?

Nope, I’m not trying to unlock all layers; just whichever layers are selected.

The plugin I’m making unlocks selected layers, does something to the layers, then relocks the layers which were previously unlocked. Changing the value to false stops it from working. The “all” in protectAll stands for the lock all button (left of the Fill dropdown).

I’ve experimented with it a bit more, and I think it’s currently impossible to do, so I might just scrap that feature.

I worked on the same feature. And in my case, I recorded all locks for all layers in the whole document. And then apply it back again for all locks in all layers.

You could also consider trying DOM instead of batchplay. Unless you need top performance.

Ok, now I understand what is going on. It is problem on PS side. @Barkin

It does explicitly lock all folder content as you set it on the group. This apply for “applyLocking” event. You can also lock layers using “set” event that shouldn’t have this issue. But in this case it works only for selected layers so you have to select them in advance.

Thanks Jarda, I’ll try using the set event instead of applyLocking later.