# How To Expand A Group

**URL:** <https://forums.creativeclouddeveloper.com/t/how-to-expand-a-group/2565>\
**Category:** UXP Plugin API\
**Created:** [February 21, 2021, 10:17pm UTC](https://forums.creativeclouddeveloper.com/t/how-to-expand-a-group/2565 "2021-02-21T22:17:48Z")\
**Posts on this page:** 11\
**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:** [February 21, 2021, 10:17pm UTC](https://forums.creativeclouddeveloper.com/t/how-to-expand-a-group/2565/1 "2021-02-21T22:17:48Z")

</div>

I have recorded an action in Alchemist to create 3 adjustment layers and add them to a Group which is all fine.

I am tryiing to work out how to then Expand that group upon completion but Alchemist does not seem to listen to that event.

Anyone got any suggestions

---

<div class="post-metadata">

**Author:** ![Pierre\_G](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/pierre_g/32/971_2.png) [@Pierre\_G](https://forums.creativeclouddeveloper.com/u/Pierre_G)\
**Post date:** [February 22, 2021, 12:25am UTC](https://forums.creativeclouddeveloper.com/t/how-to-expand-a-group/2565/2 "2021-02-22T00:25:28Z")

</div>

I’m not sure you can expand a group programmatically.

One **approach** / **workaround** could be to create a group at the very first step of your recorded action. Before adding layers that you want to have inside that group. Make sure to select that new group, and then add adjustments layers to it. The group should remain open at all times.

Further, collapsing a group with batchPlay can be done using:

```
await batchPlay(
[
   // collapse current selected group
      {
        "_obj": "collapseAllGroupsEvent",
        "_isCommand": true,
        "_options": {
          "dialogOptions": "dontDisplay"
        }
      }
],{});
```

---

<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:** [February 22, 2021, 10:44am UTC](https://forums.creativeclouddeveloper.com/t/how-to-expand-a-group/2565/3 "2021-02-22T10:44:42Z")

</div>

Thanks @Pierre_G that solution worked out great. 😃

---

<div class="post-metadata">

**Author:** ![MrL](https://avatars.discourse-cdn.com/v4/letter/m/b487fb/32.png) [@MrL](https://forums.creativeclouddeveloper.com/u/MrL)\
**Post date:** [February 25, 2021, 2:14pm UTC](https://forums.creativeclouddeveloper.com/t/how-to-expand-a-group/2565/4 "2021-02-25T14:14:44Z")

</div>

Thank you for your help.

How to collapse only the selected groups, but not all groups?

---

<div class="post-metadata">

**Author:** ![Pierre\_G](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/pierre_g/32/971_2.png) [@Pierre\_G](https://forums.creativeclouddeveloper.com/u/Pierre_G)\
**Post date:** [February 25, 2021, 2:25pm UTC](https://forums.creativeclouddeveloper.com/t/how-to-expand-a-group/2565/5 "2021-02-25T14:25:52Z")

</div>

I’m afraid it’s not possible

---

<div class="post-metadata">

**Author:** ![simonhenke](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/simonhenke/32/957_2.png) [@simonhenke](https://forums.creativeclouddeveloper.com/u/simonhenke)\
**Post date:** [February 25, 2021, 4:58pm UTC](https://forums.creativeclouddeveloper.com/t/how-to-expand-a-group/2565/6 "2021-02-25T16:58:43Z")

</div>

It is, but requires some ugly workaround:

1. Read out child layers of the group
2. Store their ids (or other referenceable property)
3. Ungroup (Delete group & Keep contents)
4. Select remembered layers
5. Regroup them

---

<div class="post-metadata">

**Author:** ![Joe](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/joe/32/1246_2.png) [@Joe](https://forums.creativeclouddeveloper.com/u/Joe)\
**Post date:** [March 10, 2021, 2:04pm UTC](https://forums.creativeclouddeveloper.com/t/how-to-expand-a-group/2565/7 "2021-03-10T14:04:58Z")

</div>

I have built a function with which you can open and close a group. With the option “recursive” you can say if all subfolders should also be closed or opened.

```
const photoshop = require("photoshop");

const collapseFolder = (expand = false, recursive = false) => {
    try {
        photoshop.action.batchPlay(
            [
                {
                    _obj: "set",
                    _target: {
                        _ref: [
                            {_property: "layerSectionExpanded"},
                            {
                                _ref: "layer",
                                _enum: "ordinal",
                                _value: "targetEnum",
                            }
                        ],
                    },
                    to: expand,
                    recursive,
                    _options: {dialogOptions: "dontDisplay"},
                },
            ],
            {synchronousExecution: true}
        );
    } catch (e) {
        console.error(e.message);
    }
}

```

I hope this helps

---

<div class="post-metadata">

**Author:** ![Pierre\_G](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/pierre_g/32/971_2.png) [@Pierre\_G](https://forums.creativeclouddeveloper.com/u/Pierre_G)\
**Post date:** [March 10, 2021, 4:08pm UTC](https://forums.creativeclouddeveloper.com/t/how-to-expand-a-group/2565/8 "2021-03-10T16:08:17Z")

</div>

That’s awesome, thank you!

---

<div class="post-metadata">

**Author:** ![MrL](https://avatars.discourse-cdn.com/v4/letter/m/b487fb/32.png) [@MrL](https://forums.creativeclouddeveloper.com/u/MrL)\
**Post date:** [March 11, 2021, 6:40am UTC](https://forums.creativeclouddeveloper.com/t/how-to-expand-a-group/2565/9 "2021-03-11T06:40:33Z")

</div>

Thank you very much. I like this.

---

<div class="post-metadata">

**Author:** ![kappasette](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/kappasette/32/3072_2.png) [@kappasette](https://forums.creativeclouddeveloper.com/u/kappasette)\
**Post date:** [December 29, 2025, 2:24am UTC](https://forums.creativeclouddeveloper.com/t/how-to-expand-a-group/2565/10 "2025-12-29T02:24:39Z")

</div>

I stumbled upon this, I tried the code and it doesn’t really work as it should, as the “recursive” option seems to have no effect. Is there a solution to do that?

---

<div class="post-metadata">

**Author:** ![AnthonyK](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@AnthonyK](https://forums.creativeclouddeveloper.com/u/AnthonyK)\
**Post date:** [January 1, 2026, 7:14pm UTC](https://forums.creativeclouddeveloper.com/t/how-to-expand-a-group/2565/11 "2026-01-01T19:14:30Z")

</div>

Not sure this is a viable option in your use case, but if you can programmatically select a layer inside the group, I think that expands the group.
