2 Replies Latest reply on Sep 4, 2012 7:47 PM by Jo_2005

    Create a new bookmark under an existing bookmark in the tree

    Jo_2005 Level 1

      I have a script to search through a time sheet report for the pages without the string "Employee Signature" and to then create new bookmarks under the existing bookmarks in the tree.

       

      So far the script will execute the book marks for the pages in the time sheet report without the string "Employee Signature".

       

      At the last bookmark executed it will insert a new child bookmark before the following console error appears.

       

      this.bookmarkRoot.children[(m + 1)] is undefined

      19:Console:Exec

      TypeError: this.bookmarkRoot.children[(m + 1)] is undefined

      19:Console:Exec

      of 128

       

      If someone can please advise where the script is going wrong it will be very much appreciated.  The script is as follows:

       

      var ckWords; // word pair to test
      var bFound = false; // logical status of found words
      // loop through pages
      for (var m = 0; m < this.numPages; m++ ) {
         bFound = false; // set found flag to false
         numWords = this.getPageNumWords(m); // number of words on page
         // loop through the words on page
         for (var j = 0; j < numWords-1; j++) {
            // get word pair to test
            ckWords = this.getPageNthWord(m, j) + ' ' + this.getPageNthWord(m, j + 1); // test words
            // check to see if word pair is 'Employee Signature' string is present
            if ( ckWords == "Employee Signature") {
               bFound = true; // indicate found logical value
               break; // no need to further test for this page
            } // end Employee Signature
         } // end word loop
         // test to see if words not found
         if(bFound == false) {
              var nLastSub = this.bookmarkRoot.children[(m+1)].children.length-1;

              this.bookmarkRoot.children[m+1].children[nLastSub].execute();
      this.bookmarkRoot.children[m+1].children[nLastSub].createChild("Employee Signature Reqd", "this.pageNum = " + (m+1));

          } // end not found on page  
      } // end page loop

       

      Thank you

        • 1. Re: Create a new bookmark under an existing bookmark in the tree
          try67 MVP & Adobe Community Professional

          Why are you using a variable ("m") that points to a page number to point to a bookmark? The two are not the same, you know...

          • 2. Re: Create a new bookmark under an existing bookmark in the tree
            Jo_2005 Level 1

            I need to place a new bookmark underneath the existing bookmarks for the pages that do not contain the words "employee signature".

             

            I am not sure how to refer to the existing bookmark on those pages.

             

            Tried to revise the script, and now all of the new bookmarks are created underneath all of the existing bookmarks for every page in a continuous loop.

             

            I need a new single bookmark underneath the exisiting bookmarks on the pages that do not contain the words "employee signature".

             

            Can you please help?

             

            var ckWords; // word pair to test
            var bFound = false; // logical status of found words
            // loop through pages
            for (var m = 0; m < this.numPages; m++ ) {
               bFound = false; // set found flag to false
               numWords = this.getPageNumWords(m); // number of words on page
               // loop through the words on page
               for (var j = 0; j < numWords-1; j++) {
                  // get word pair to test
                  ckWords = this.getPageNthWord(m, j) + ' ' + this.getPageNthWord(m, j + 1); // test words
                  // check to see if word pair is 'Employee Signature' string is present
                  if ( ckWords == "Employee Signature") {
                     bFound = true; // indicate found logical value
                     break; // no need to further test for this page
                  } // end Employee Signature
               } // end word loop
               // test to see if words not found
               if(bFound == false) {
            for (var i=0; i < this.bookmarkRoot.children.length; i++)
            {
                    var nLastSub = this.bookmarkRoot.children[i].children.length-1;

                    this.bookmarkRoot.children[i].children[nLastSub].execute();
            this.bookmarkRoot.children[i].children[nLastSub].createChild("Next Page", "this.pageNum = " + (m+1));

                } // end not found on page  
            } // end page loop
            }