BatchPlay: Select layer doesn't work when multiple layers have the same name

Hello,

We’re rebuilding our previous CEP panels to UXP plugins and face some issues. The most recent issue we found is caused by the inability to select layers when a document has duplicate layer names.

Example:

When using Alchemist you can see that in the event only the id changes. Unfortunately the bottom layer is always select. I’m using the code below.

const batchPlay = require("photoshop").action.batchPlay;
const result = batchPlay(
[
    {
        "_obj": "select",
        "_target": [{ "_ref": "layer", "_name": "dupname" }],
        "makeVisible": true,
        "layerID": [3],
        "_isCommand": false,
        "_options": { "dialogOptions": "dontDisplay" }
    }
], {
"synchronousExecution": false,
"modalBehavior": "fail"
});

The code is copy pasted from Alchemist. Has anyone face the same issue and found a possible work around for this?

Found a solution. It seems to be possible to also pass the ID in the target object. The solution was to refer to the id property instead of the name property:

const batchPlay = require("photoshop").action.batchPlay;
const result = batchPlay(
[
   {
      "_obj": "select",
      "_target": [{ "_ref": "layer", "_id": 3}],
      "makeVisible": false,
      "layerID": [3],
      "_isCommand": false,
      "_options": {"dialogOptions": "dontDisplay"}
   }
],{ "synchronousExecution": false, "modalBehavior": "fail"});