# Deleting Layer Contents

**URL:** <https://forums.creativeclouddeveloper.com/t/deleting-layer-contents/3439>\
**Category:** UXP Plugin API\
**Created:** [August 3, 2021, 9:38pm UTC](https://forums.creativeclouddeveloper.com/t/deleting-layer-contents/3439 "2021-08-03T21:38:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![blastframe](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/blastframe/32/1519_2.png) [@blastframe](https://forums.creativeclouddeveloper.com/u/blastframe)\
**Post date:** [August 3, 2021, 9:38pm UTC](https://forums.creativeclouddeveloper.com/t/deleting-layer-contents/3439/1 "2021-08-03T21:38:04Z")

</div>

Hello,  
I have a layer selected, run a Select \> All command, and tried executing this function, but nothing happens:

```auto
async function clear()
{
  const result = await batchPlay(
  [
    {
     "_obj": "delete",
     "_isCommand": true
    }
  ],{
     "synchronousExecution": false
  });
}

```

`batchPlay` is working for other Photoshop commands that I’ve gotten from `eventNotifier`. Can anyone help me understand what’s going wrong, please? Thank you.

---

<div class="post-metadata">

**Author:** ![blastframe](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/blastframe/32/1519_2.png) [@blastframe](https://forums.creativeclouddeveloper.com/u/blastframe)\
**Post date:** [August 3, 2021, 10:05pm UTC](https://forums.creativeclouddeveloper.com/t/deleting-layer-contents/3439/2 "2021-08-03T22:05:38Z")

</div>

If I add a Select descriptor before the Delete descriptor, it works.

Here is the code (with a Deselect descriptor at the end):

```auto
async function clear()
{
  const result = await batchPlay(
  [
     {
        "_obj": "set",
        "_target": [
           {
              "_ref": "channel",
              "_property": "selection"
           }
        ],
        "to": {
           "_enum": "ordinal",
           "_value": "allEnum"
        }
     },
     {
       "_obj": "delete",
     },
     {
        "_obj": "set",
        "_target": [
           {
              "_ref": "channel",
              "_property": "selection"
           }
        ],
        "to": {
           "_enum": "ordinal",
           "_value": "none"
        }
     }
  ],{
     "synchronousExecution": false
  });
}

```

It’s strange that the Edit \> Clear command event doesn’t include “\_target” information.
