Select_layername is it corect?

js code:
const select_layername = async () => {
    const layers = await require("photoshop").app.activeDocument.layers;

    for (layer of layers) {
        if ( == "Saturation") {
            let layer = app.activeDocument.activeLayers[0];
            layer.visible = !layer.visible
    console.log("Select_Layer result!!!")

I want it to show and hide the layer specified by the code.
Mohamad Fathi…

Does it work? If it does, then it’s correct. But I assume it works not as you’re expecting, because you’re always changing visibility of the first active layer. And again, this mistake is a pure JS mistake, which is not really in the UXP scope. You need to learn at least basic JS concepts first

1 Like

Thank you, my friend,I checked my mistake and solved it، you are my guardian angel and I respect your suggestions and I admire your work and respect you very much because you are a service person and I appreciate your help is always in place .
And I would also like to thank you about weapack.js
I have checked my mistakes and fixed them, and all thanks and appreciation belong to you, my friend.
With regards…
Mohamed Fathi

It would be nice if you shared your fix and marked that post as a solution. It helps keep forum clean and it also helps for others to find solutions much easier and faster

Hello, kamalakas .
You’re right, sorry for the delay, but you know, because of work, I work as a chartered accountant at Ford and in my spare time I practice my hobby.

This is clean and working code :100:

///////// MY WORKE MOHAMAD FATHI   🚀🚀  BOOST_Show_Hide🚀🚀    /////////
// BOOST_Show_Hide...(How to change layer BOOST_Show_Hide by name inside a group).

const BOOST_Show_Hide = async () => {
    let wantedLayer = "BOOST"
    await ExecuteAsModal(async () => {
        let doc = app.activeDocument;
        doc.layers.forEach(layer => {
            if (layer.kind == "group") {
                layer.layers.forEach(gLayer => {
                    //now looping through group layers : one level deeper
                    if ( == wantedLayer) {
                        //layer found
                        // you can also check its kind if you like to
                        gLayer.visible = !gLayer.visible

    }, { "commandName": "layer visible..." }) //executeAsModal :: END
    console.log("BOOST_Show_Hide Result!!!")

With regards…
Mohamed Fathi… :wine_glass: