# Help With Moving a Layer With API 2

**URL:** <https://forums.creativeclouddeveloper.com/t/help-with-moving-a-layer-with-api-2/4014>\
**Category:** UXP Plugin API\
**Created:** [December 12, 2021, 12:38pm UTC](https://forums.creativeclouddeveloper.com/t/help-with-moving-a-layer-with-api-2/4014 "2021-12-12T12:38:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![IanBarber](https://avatars.discourse-cdn.com/v4/letter/i/94ad74/32.png) [@IanBarber](https://forums.creativeclouddeveloper.com/u/IanBarber)\
**Post date:** [December 12, 2021, 12:38pm UTC](https://forums.creativeclouddeveloper.com/t/help-with-moving-a-layer-with-api-2/4014/1 "2021-12-12T12:38:41Z")

</div>

Reading the documentation, this is what it says about moving layers…

- Arrange layers with `layer.move(targetLayer, Constants.ElementPlacement)` . Added `Constants.ElementPlacement` for moving layers: `"placeAfter"` (place below a layer, below group if group layer), `"placeBefore"` (place above a layer, above group if group layer), and `"placeInside"` (inside group layers only).
- Send a layer to the back or bring a layer to the front with `layer.sendToBack()` and `layer.bringToFront()` . If `layer` is within a group, the commands will operate within that group.

The one I am interested in is moving a layer outside a group

I have tried various ways but cannot seem to get any to work

```auto
   const layer = app.activeDocument.activeLayers[0]
   layer.move(layer, constants.ElementPlacement.PLACEBEFORE)

```

Can anyone show me an example on how to do this please

---

<div class="post-metadata">

**Author:** ![IanBarber](https://avatars.discourse-cdn.com/v4/letter/i/94ad74/32.png) [@IanBarber](https://forums.creativeclouddeveloper.com/u/IanBarber)\
**Post date:** [December 17, 2021, 9:07am UTC](https://forums.creativeclouddeveloper.com/t/help-with-moving-a-layer-with-api-2/4014/2 "2021-12-17T09:07:45Z")

</div>

Im still struggling with this if any of you Whiz Kids can help, it would be appreciated

---

<div class="post-metadata">

**Author:** ![Karmalakas](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/karmalakas/32/1048_2.png) [@Karmalakas](https://forums.creativeclouddeveloper.com/u/Karmalakas)\
**Post date:** [December 17, 2021, 9:27am UTC](https://forums.creativeclouddeveloper.com/t/help-with-moving-a-layer-with-api-2/4014/3 "2021-12-17T09:27:39Z")

</div>

> [@IanBarber](#):
>
> `layer.move(layer, constants.ElementPlacement.PLACEBEFORE)`

You are trying to move a `layer` before that same `layer`. I suppose nothing should happen in such case

---

<div class="post-metadata">

**Author:** ![IanBarber](https://avatars.discourse-cdn.com/v4/letter/i/94ad74/32.png) [@IanBarber](https://forums.creativeclouddeveloper.com/u/IanBarber)\
**Post date:** [December 17, 2021, 9:29am UTC](https://forums.creativeclouddeveloper.com/t/help-with-moving-a-layer-with-api-2/4014/4 "2021-12-17T09:29:17Z")

</div>

Do I have the Syntax right if not the wrong Constant

---

<div class="post-metadata">

**Author:** ![Karmalakas](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/karmalakas/32/1048_2.png) [@Karmalakas](https://forums.creativeclouddeveloper.com/u/Karmalakas)\
**Post date:** [December 17, 2021, 9:31am UTC](https://forums.creativeclouddeveloper.com/t/help-with-moving-a-layer-with-api-2/4014/5 "2021-12-17T09:31:13Z")

</div>

I guess neither syntax nor constant are wrong.  
From the docs:

> Moves the layer relative to the layer specified in parameters.

You are moving your `layer` above that exact same `layer`. How do you imagine this should work? You need to provide a different layer as first argument, then your `layer` would be placed before that other layer (if it’s not there yet)

```auto
layer.move(someOtherLayer, constants.ElementPlacement.PLACEBEFORE)

```
