17 Replies Latest reply on Jun 15, 2016 8:42 AM by try67

    Variable is null (getNthFieldName) not sure why

    alexh90310518 Level 1


      I'm using the script below to loop through all the fields in my document and checking if they are required.

      var pgGlzMain = this.getTemplate("MainAddSlider");
      for (var i=0; i<this.numFields; i++) {
           var fldAll = this.getField(this.getNthFieldName[i]);
           if (fldAll.required == true) {
                app.alert("Please fill in all required fields (Marked red) before proceeding");
           else {
                pgGlzMain.spawn({nPage: pageNum + 1, bRename: true, bOverlay: false});
                pageNum = this.pageNum+1;

      However when I run this it tells me that fldAll is Null.

      TypeError: fldAll is null

      4:Field:Mouse Up

      I'm not exactly sure as to why it is null but I believe it is to do with the getNthFieldName[i] part.

      Any help is much appreciated.

      Thank you in advance.