# How to use code to collapse the selected l layer group in uxp?

**URL:** <https://forums.creativeclouddeveloper.com/t/how-to-use-code-to-collapse-the-selected-l-layer-group-in-uxp/2591>\
**Category:** Photoshop\
**Tags:** uxp, javascript\
**Created:** [February 25, 2021, 12:26pm UTC](https://forums.creativeclouddeveloper.com/t/how-to-use-code-to-collapse-the-selected-l-layer-group-in-uxp/2591 "2021-02-25T12:26:11Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Zob](https://avatars.discourse-cdn.com/v4/letter/z/87869e/32.png) [@Zob](https://forums.creativeclouddeveloper.com/u/Zob)\
**Post date:** [March 9, 2023, 4:45pm UTC](https://forums.creativeclouddeveloper.com/t/how-to-use-code-to-collapse-the-selected-l-layer-group-in-uxp/2591/3 "2023-03-09T16:45:45Z")

</div>

This is a really great command! It collapses _all_ group layers in the document, which definitely has utility. If a person just needs to collapse or show a single group, that command is located here.  
(I know you know already Pierre, I am including this for easy navigation)

> [@How To Expand A Group](http://forums.creativeclouddeveloper.com/t/how-to-expand-a-group/2565/7):
>
> 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"…

---

_[View the full topic](https://forums.creativeclouddeveloper.com/t/how-to-use-code-to-collapse-the-selected-l-layer-group-in-uxp/2591)._
