Problem with placedLayerReplaceContents. It does nothing, not even an error

Hey,

I’m building my first PS Plugin and got a problem with placedLayerReplaceContents.
I have this function:

async function selectArtwork() {
  console.log("Starting selectArtwork function");

  try {
    // Dateiauswahldialog
    const file = await fs.getFileForOpening({ types: ["png", "jpg", "jpeg", "webp"] });
    if (!file) {
      console.log("No file selected");
      return;
    }

    await require("photoshop").core.executeAsModal(async () => {
      try {
        const artLayerId = 10512; // Die ID des Artlayers

        // Dann den Inhalt ersetzen
        const token = await fs.createSessionToken(file);
        
        await batchPlay(
          [
            {
              _obj: "placedLayerReplaceContents",
              null: { _path: token },
              _target: [{ _ref: "layer", _id: artLayerId }]
            }
          ],
          { synchronousExecution: true }
        );
        
        console.log("Artwork updated successfully");
      } catch (error) {
        console.error("Error updating artwork:", error);
      }
    });
  } catch (error) {
    console.error("Error in selectArtwork function:", error);
  }

  console.log("selectArtwork function completed");
}

Whenever i select an img (btw is there a possibility to just say “all img types”? I found fileTypes.images in the FileSystemProvider JavaScript Reference Examples but fileTypes is not declared…) it just runs perfectly but doesn’t change the Layer Content.
I have “localFileSystem”: “fullAccess” in my Manifest.
I also tried to select the Layer first but this didn’t change anything.

Thanks
Azami

Is your artLayerId correct? It should be different almost everytime you run it.

The ID is definitely correct (i just forgot to change it in my post, i was testing with other layers. whoops)
image

When i change the Content of the Layer manually i get the same ID (Right Click → Replace Content).