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

**URL:** <https://forums.creativeclouddeveloper.com/t/problem-with-placedlayerreplacecontents-it-does-nothing-not-even-an-error/8146>\
**Category:** UXP Plugin API\
**Tags:** uxp, javascript, batch-play\
**Created:** [July 16, 2024, 4:40pm UTC](https://forums.creativeclouddeveloper.com/t/problem-with-placedlayerreplacecontents-it-does-nothing-not-even-an-error/8146 "2024-07-16T16:40:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Azami](https://avatars.discourse-cdn.com/v4/letter/a/d2c977/32.png) [@Azami](https://forums.creativeclouddeveloper.com/u/Azami)\
**Post date:** [July 16, 2024, 4:40pm UTC](https://forums.creativeclouddeveloper.com/t/problem-with-placedlayerreplacecontents-it-does-nothing-not-even-an-error/8146/1 "2024-07-16T16:40:43Z")

</div>

Hey,

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

```auto
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

---

<div class="post-metadata">

**Author:** ![Jarda](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/jarda/32/1909_2.png) [@Jarda](https://forums.creativeclouddeveloper.com/u/Jarda)\
**Post date:** [July 16, 2024, 6:30pm UTC](https://forums.creativeclouddeveloper.com/t/problem-with-placedlayerreplacecontents-it-does-nothing-not-even-an-error/8146/2 "2024-07-16T18:30:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Azami](https://avatars.discourse-cdn.com/v4/letter/a/d2c977/32.png) [@Azami](https://forums.creativeclouddeveloper.com/u/Azami)\
**Post date:** [July 17, 2024, 5:51pm UTC](https://forums.creativeclouddeveloper.com/t/problem-with-placedlayerreplacecontents-it-does-nothing-not-even-an-error/8146/3 "2024-07-17T17:51:34Z")

</div>

The ID is definitely correct (i just forgot to change it in my post, i was testing with other layers. whoops)  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/xdplugins/original/2X/2/24e5f3f783287db491f69e27b2972d528eaa4515.png)

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