title: Photoshop JS Error: General Photoshop error occurred. This functionality may not be available in this version of Photoshop
body: <p>I am getting a "General Photoshop error occurred. This functionality may not be available in this version of Photoshop." error when I run the following code:</p>
  
  <pre><code>var watermarklineGroup  = app.activeDocument.layerSets.getByName('WATERMARK.LINE');
  var snGroup             = app.activeDocument.layerSets.getByName('SERIAL NUMBERS');
  
  var wmLayerOne          = watermarklineGroup.layers[0];
  var wmLayerTwo          = watermarklineGroup.layers[1];
  var wmLayerThree        = watermarklineGroup.layers[2];
  var wmLayerFour         = watermarklineGroup.layers[3];
  var wmLayerFive         = watermarklineGroup.layers[4];
  var wmLayerSix          = watermarklineGroup.layers[5];
  var wmLayerSeven        = watermarklineGroup.layers[6];
  var wmLayerEight        = watermarklineGroup.layers[7];
  
  var snLayerOne          = snGroup.layers[0];
  var snLayerTwo          = snGroup.layers[1];
  var snLayerThree        = snGroup.layers[2];
  var snLayerFour         = snGroup.layers[3];
  var snLayerFive         = snGroup.layers[4];
  var snLayerSix          = snGroup.layers[5];
  var snLayerSeven        = snGroup.layers[6];
  var snLayerEight        = snGroup.layers[7];
  
  var intFirstSetOfFive   = CreateRandom5 ();
  var intSecondSetOfFive  = CreateRandom5 ();
  var intThirdSetOfFive   = CreateRandom5 ();
  
  
  (function main(){        
      WriteGeneratedNumbers();
  })();
  
  
  function CreateRandom5(){
      min = Math.ceil(10000);
      max = Math.floor(99999);
      return Math.floor(Math.random() * (max - min));
  }
  
  function WriteGeneratedNumbers(){
      for (var i = 0; i&gt;8; i++){        
  
          snGroup.layers[i].textItem.contents             = intFirstSetOfFive + " " + intSecondSetOfFive + " " + intThirdSetOfFive;
  
          watermarklineGroup.layers[i].textItem.contents  = intFirstSetOfFive + intSecondSetOfFive + intThirdSetOfFive;
  
          alert(snGroup.layers[i].textItem.contents);
          alert(watermarklineGroup.layers[i].textItem.contents);
  
          intThirdSetOfFive = CreateRandom5 ();
          i++;
       }
  }
  </code></pre>
  
  <p>Currently the variables are redundant, but I just wanted to refresh on my JS (its been 10 years). I dont have any styling on my text layers.</p>
  
  <p><a href="https://i.stack.imgur.com/Im2zs.jpg" rel="nofollow noreferrer">ScreenShot of Layers Panel</a></p>