Check to see if layer has a mask

Can’t quite figure out how to make photoshop check to see if a layer has a mask and return a value

Is there a way in UXP like

app.activeDocument.activeLayers[0]. //getMaskValueSomehow

Or I assume I need to somehow get a result off running a batch play code like the below?

 {
      "_obj": "get",
      "_target": [
         {
            "_ref": "channel",
            "_enum": "channel",
            "_value": "mask"
         }
      ],
 }
  

This method returns true or false for anyone that needs it

layer = app.activeDocument.activeLayers[0].name

   const result = await batchPlay(

      [

         {

            "_obj": "get",

            "_target": [

               {

                  "_property": "hasUserMask"

               },

               {

                  "_ref": "layer",

                  "_name": layer

               },

            ],

         }

      ],{

         "synchronousExecution": false,

         "modalBehavior": "fail"

      });

      console.log(result[0].hasUserMask)

}
1 Like