11 Replies Latest reply on Apr 2, 2015 11:55 AM by JenLedger

    JavaScript works in Pro but not Reader - NotAllowedError

    JenLedger Level 1

      I have created a web form in Adobe XI Pro. We have some progress bars at the top with number of fields completed type of thing. All of my JavaScript works perfectly in Acrobat. I save it like so Save As Other > Reader Extended PDF > Enable More Tools. Again everything works in Acrobat. When I open the PDF in Reader the JavaScript won't work. My forms still fill I can save and such, but no JavaScript progress bars. We create this form frequently and it has always worked. I assume it is some sort of new update to Adobe XI Pro. Here is the error I receive in the debugger:


      NotAllowedError: Security settings prevent access to this property or method.

      Doc.title:27:Document-Level:Progress

       

      I was thinking it might be related to the security settings these are the only 2 things not allowed.

      Document Assembly : Not Allowed

      Page Extraction: Not Allowed

       

      But as I read through the forums I am not sure that is actually the problem. Any ideas?

       

      Thanks in advance,

      Jen

        • 1. Re: JavaScript works in Pro but not Reader - NotAllowedError
          George_Johnson MVP & Adobe Community Professional

          Can you post the code you're using for the progress bar?

          • 2. Re: JavaScript works in Pro but not Reader - NotAllowedError
            JenLedger Level 1

            //Define all required fields

            this.first = this.getField("FirstName");

            this.family = this.getField("FamilyName");

            this.addressOne = this.getField("AddressOne");

            this.addressTwo = this.getField("AddressTwo");

             

            //Load them all into an array

            this.REQUIRED = [first, family, addressOne, addressTwo ];

             

            //Define the colors to be used

            this.gray = ["RGB", 0.208, 0.208, 0.208];

            this.amber = ["RGB", 0.992, 0.905, 0];

            this.red = ["RGB", 0.937, 0.282, 0.212];

            this.green = ["RGB", 0.431, 0.710, 0.016];

             

             

            //Call the document-level functions to update the Checklist

            updateAll();

            function updateAll()

            {

              Dupdate();

            }

             

             

            ///

            //Updates the P46 entry.

            ///

            /*----------------NEW-------------------*/

            function Dupdate()

            {

              this.DfieldCount = 0

              this.DnumComplete = 0;

             

              //Get all required fields in the form -----------

              var first = this.getField("FirstName");

              var family = this.getField("FamilyName");

              var addressOne = this.getField("AddressOne");

              var addressTwo = this.getField("AddressTwo");

             

              var dFields = [first, family, addressOne, addressTwo];

             

              //Check required fields for completion and visibility

              for (var i in dFields)

              {

              if (dFields[i].display == display.visible)

              {

              this.DfieldCount++;

              if (dFields[i].value != "" && dFields[i].name != "ReceiveCopy")

              {

              this.DnumComplete++;

              }

             

              if(dFields[i].name == "ReceiveCopy")

              {

              if(dFields[i].value == "Yes" || dFields[i].value == "No")

              this.DnumComplete++;

              }

              }

              }

             

              var t = this.getField("PFortySix");

              if (DnumComplete == 0)

              {

              t.fillColor = this.gray;

              this.getField("DProgress").userName = "";

              }

              else if (DnumComplete < DfieldCount)

              {

              t.fillColor = this.amber;

              this.getField("DProgress").userName = "";

              }

              else

              {

              t.fillColor = this.green;

              }

             

              this.getField("DProgress").value = this.DnumComplete + "/" + this.DfieldCount;

              if (this.DnumComplete == this.DfieldCount) this.getField("DProgress").userName = "Done";

            }

            • 3. Re: JavaScript works in Pro but not Reader - NotAllowedError
              try67 MVP & Adobe Community Professional

              The error message is from something else, because in this code the title

              property is never accessed, so it could not cause this error message.

              • 4. Re: JavaScript works in Pro but not Reader - NotAllowedError
                JenLedger Level 1

                You mean "Progress"? That is the name of the main script.Capture.PNG

                • 5. Re: JavaScript works in Pro but not Reader - NotAllowedError
                  Bernd Alheit Adobe Community Professional & MVP

                  Look at line 27 of function Progress.

                  • 6. Re: JavaScript works in Pro but not Reader - NotAllowedError
                    try67 MVP & Adobe Community Professional

                    The first lines in that screenshot do not correspond to the first lines of the code you posted. Post the full code.

                    • 7. Re: JavaScript works in Pro but not Reader - NotAllowedError
                      JenLedger Level 1

                      //Turn off the warnings when JavaScript is enabled

                      this.getField("JavascriptWarning").display = display.visible;

                      this.getField("ProgressTracking").display = display.visible;

                       

                       

                      //Required fields warning

                      this.alerted = false;

                       

                       

                      //Define all required fields

                      this.first = this.getField("FirstName");

                      this.family = this.getField("FamilyName");

                      this.addressOne = this.getField("AddressOne");

                      this.addressTwo = this.getField("AddressTwo");

                      this.postcodeOne = this.getField("Postcode-1");

                      this.daytimeTelephone = this.getField("DaytimeTelephone");

                      this.payrollReference = this.getField("PayrollReference");

                       

                       

                      //---P46

                      this.nationalOne = this.getField("NationalInsurance1");

                      this.nationalTwo = this.getField("NationalInsurance2");

                      this.nationalThree = this.getField("NationalInsurance3");

                      this.nationalFour = this.getField("NationalInsurance4");

                      this.nationalFive = this.getField("NationalInsurance5");

                      this.nationalSix = this.getField("NationalInsurance6");

                      this.nationalSeven = this.getField("NationalInsurance7");

                      this.nationalEight = this.getField("NationalInsurance8");

                      this.nationalNine = this.getField("NationalInsurance9");

                      this.title = this.getField("Title");

                      this.surnameOne = this.getField("SurnameFamilyName-1");

                      this.firstOne = this.getField("FirstorGivenName-1");

                      this.dobOne = this.getField("DOB-1");

                      this.dobTwo = this.getField("DOB-2");

                      this.dobThree = this.getField("DOB-3");

                      this.dobFour = this.getField("DOB-4");

                      this.dobFive = this.getField("DOB-5");

                      this.dobSix = this.getField("DOB-6");

                      this.dobSeven = this.getField("DOB-7");

                      this.dobEight = this.getField("DOB-8");

                      this.houseOne = this.getField("HouseOrFlatNumber-1");

                      this.restAddressOne = this.getField("RestOfAddress-1");

                      this.dateOne = this.getField("Date-1");

                       

                       

                      //---Leidos Employee Bank Details For Payroll

                      this.employeeNumber = this.getField("EmployeeNumber");

                      this.bankName = this.getField("BankName");

                      this.bankAddressOne = this.getField("BankAddressOne");

                      this.bankAddressTwo = this.getField("BankAddressTwo");

                      this.bankPostcodeOne = this.getField("BankPostcode-1");

                      this.bankSortCodeOne = this.getField("BankSortCode-1");

                      this.bankAccountNumber = this.getField("BankAccountNumber-1");

                      this.effectiveDate = this.getField("EffectiveDate");

                       

                       

                      //---Baseline Personnel Security Standard

                      this.birthPlace = this.getField("PlaceOfBirth");

                      this.birthNationality = this.getField("NationalityAtBirth");

                      this.presentNationality = this.getField("PresentNationality");

                       

                       

                      //Load them all into an array

                      this.REQUIRED = [first, family, addressOne, addressTwo, postcodeOne, daytimeTelephone, payrollReference, nationalOne, nationalTwo, nationalThree, nationalFour, nationalFive, nationalSix, nationalSeven, nationalEight, nationalNine, title, surnameOne, firstOne, dobOne, dobTwo, dobThree, dobFour, dobFive, dobSix, dobSeven, dobEight, houseOne, restAddressOne, dateOne, employeeNumber, bankName, bankAddressOne, bankAddressTwo, bankPostcodeOne, bankSortCodeOne, bankAccountNumber, effectiveDate, birthPlace, birthNationality, presentNationality ];

                       

                       

                       

                      //Define the colors to be used

                      this.gray = ["RGB", 0.208, 0.208, 0.208];

                      this.amber = ["RGB", 0.992, 0.905, 0];

                      this.red = ["RGB", 0.937, 0.282, 0.212];

                      this.green = ["RGB", 0.431, 0.710, 0.016];

                       

                       

                      //Call the document-level functions to update the Checklist

                      updateAll();

                      function updateAll()

                      {

                        Dupdate();

                        EOWupdate();

                        LNHupdate();

                        EBDupdate();

                        BPSSupdate();

                      }

                       

                       

                      ///

                      //Updates the P46 entry.

                      ///

                      /*----------------NEW-------------------*/

                      function Dupdate()

                      {

                        this.DfieldCount = 0

                        this.DnumComplete = 0;

                       

                        //Get all required fields in the form ----------- ecFirst, ecNationalOne

                        var postcodeOne = this.getField("Postcode-1");

                        var nationalOne = this.getField("NationalInsurance1");

                        var nationalTwo = this.getField("NationalInsurance2");

                        var nationalThree = this.getField("NationalInsurance3");

                        var nationalFour = this.getField("NationalInsurance4");

                        var nationalFive = this.getField("NationalInsurance5");

                        var nationalSix = this.getField("NationalInsurance6");

                        var nationalSeven = this.getField("NationalInsurance7");

                        var nationalEight = this.getField("NationalInsurance8");

                        var nationalNine = this.getField("NationalInsurance9");

                        var title = this.getField("Title");

                        var surnameOne = this.getField("SurnameFamilyName-1");

                        var firstOne = this.getField("FirstorGivenName-1");

                        var dobOne = this.getField("DOB-1");

                        var dobTwo = this.getField("DOB-2");

                        var dobThree = this.getField("DOB-3");

                        var dobFour = this.getField("DOB-4");

                        var dobFive = this.getField("DOB-5");

                        var dobSix = this.getField("DOB-6");

                        var dobSeven = this.getField("DOB-7");

                        var dobEight = this.getField("DOB-8");

                        var houseOne = this.getField("HouseOrFlatNumber-1");

                        var restAddressOne = this.getField("RestOfAddress-1");

                        var dateOne = this.getField("Date-1");

                        var dFields = [postcodeOne, nationalOne, nationalTwo, nationalThree, nationalFour, nationalFive, nationalSix, nationalSeven, nationalEight, nationalNine, title, surnameOne, firstOne, dobOne, dobTwo, dobThree, dobFour, dobFive, dobSix, dobSeven, dobEight, houseOne, restAddressOne, dateOne];

                       

                        //Check required fields for completion and visibility

                        for (var i in dFields)

                        {

                        if (dFields[i].display == display.visible)

                        {

                        this.DfieldCount++;

                        if (dFields[i].value != "" && dFields[i].name != "ReceiveCopy")

                        {

                        this.DnumComplete++;

                        }

                       

                        if(dFields[i].name == "ReceiveCopy")

                        {

                        if(dFields[i].value == "Yes" || dFields[i].value == "No")

                        this.DnumComplete++;

                        }

                        }

                        }

                       

                        var t = this.getField("PFortySix");

                        if (DnumComplete == 0)

                        {

                        t.fillColor = this.gray;

                        this.getField("DProgress").userName = "";

                        }

                        else if (DnumComplete < DfieldCount)

                        {

                        t.fillColor = this.amber;

                        this.getField("DProgress").userName = "";

                        }

                        else

                        {

                        t.fillColor = this.green;

                        }

                       

                        this.getField("DProgress").value = this.DnumComplete + "/" + this.DfieldCount;

                        if (this.DnumComplete == this.DfieldCount) this.getField("DProgress").userName = "Done";

                      }

                       

                       

                      ///

                      //Updates the Leidos Expression of Wish entry.

                      ///

                      /*----------------NEW-------------------*/

                      function EOWupdate()

                      {

                        this.EOWfieldCount = 0

                        this.EOWnumComplete = 0;

                       

                        //Get all required fields in the form ----------- ecFirst, ecFamily, ecAddressOne, ecAddressTwo, ecPostcodeOne, ecNationalOne

                        var first = this.getField("FirstName");

                        var family = this.getField("FamilyName");

                        var addressOne = this.getField("AddressOne");

                        var addressTwo = this.getField("AddressTwo");

                        var postcodeOne = this.getField("Postcode-1");

                        var daytimeTelephone = this.getField("DaytimeTelephone");

                        var payrollReference = this.getField("PayrollReference");

                        var nationalOne = this.getField("NationalInsurance1");

                        var nationalTwo = this.getField("NationalInsurance2");

                        var nationalThree = this.getField("NationalInsurance3");

                        var nationalFour = this.getField("NationalInsurance4");

                        var nationalFive = this.getField("NationalInsurance5");

                        var nationalSix = this.getField("NationalInsurance6");

                        var nationalSeven = this.getField("NationalInsurance7");

                        var nationalEight = this.getField("NationalInsurance8");

                        var nationalNine = this.getField("NationalInsurance9");

                        var dobOne = this.getField("DOB-1");

                        var dobTwo = this.getField("DOB-2");

                        var dobThree = this.getField("DOB-3");

                        var dobFour = this.getField("DOB-4");

                        var dobFive = this.getField("DOB-5");

                        var dobSix = this.getField("DOB-6");

                        var dobSeven = this.getField("DOB-7");

                        var dobEight = this.getField("DOB-8");

                        var eowFields = [first, family, addressOne, addressTwo, postcodeOne, daytimeTelephone, payrollReference, nationalOne, nationalTwo, nationalThree, nationalFour, nationalFive, nationalSix, nationalSeven, nationalEight, nationalNine, dobOne, dobTwo, dobThree, dobFour, dobFive, dobSix, dobSeven, dobEight ];

                       

                        //Check required fields for completion and visibility

                        for (var i in eowFields)

                        {

                        if (eowFields[i].display == display.visible)

                        {

                        this.EOWfieldCount++;

                        if (eowFields[i].value != "")

                        {

                        this.EOWnumComplete++;

                        }

                        }

                        }

                       

                        var t = this.getField("ExpressionWish");

                        if (EOWnumComplete == 0)

                        {

                        t.fillColor = this.gray;

                        this.getField("EOWProgress").userName = "";

                        }

                        else if (EOWnumComplete < EOWfieldCount)

                        {

                        t.fillColor = this.amber;

                        this.getField("EOWProgress").userName = "";

                        }

                        else

                        {

                        t.fillColor = this.green;

                        }

                       

                        this.getField("EOWProgress").value = this.EOWnumComplete + "/" + this.EOWfieldCount;

                        if (this.EOWnumComplete == this.EOWfieldCount) this.getField("EOWProgress").userName = "Done";

                      }

                       

                       

                      ///

                      //Updates the Leidos Limited New Hires entry.

                      ///

                      /*----------------NEW-------------------*/

                      function LNHupdate()

                      {

                        this.LNHfieldCount = 0

                        this.LNHnumComplete = 0;

                       

                        //Get all required fields in the form ----------- ecFirst, ecFamily

                        var first = this.getField("FirstName");

                        var family = this.getField("FamilyName");

                        var lnhFields = [first, family ];

                       

                        //Check required fields for completion and visibility

                        for (var i in lnhFields)

                        {

                        if (lnhFields[i].display == display.visible)

                        {

                        this.LNHfieldCount++;

                        if (lnhFields[i].value != "")

                        {

                        this.LNHnumComplete++;

                        }

                        }

                        }

                       

                        var t = this.getField("LimitedNewHires");

                        if (LNHnumComplete == 0)

                        {

                        t.fillColor = this.gray;

                        }

                        else if (LNHnumComplete < LNHfieldCount)

                        {

                        t.fillColor = this.amber;

                        }

                        else

                        {

                        t.fillColor = this.green;

                        }

                       

                        this.getField("LNHProgress").value = this.LNHnumComplete + "/" + this.LNHfieldCount;

                        if (this.LNHnumComplete == this.LNHfieldCount) this.getField("LNHProgress").userName = "Done";

                        else this.getField("LNHProgress").userName = "";

                      }

                       

                       

                      ///

                      //Updates the Leidos Employee Bank Details for Payroll entry.

                      ///

                      /*----------------NEW-------------------*/

                      function EBDupdate()

                      {

                        this.EBDfieldCount = 0

                        this.EBDnumComplete = 0;

                       

                        //Get all required fields in the form -----------

                        var first = this.getField("FirstName");

                        var family = this.getField("FamilyName");

                        var employeeNumber = this.getField("EmployeeNumber");

                        var bankName = this.getField("BankName");

                        var bankAddressOne = this.getField("BankAddressOne");

                        var bankAddressTwo = this.getField("BankAddressTwo");

                        var bankPostcodeOne = this.getField("BankPostcode-1");

                        var bankSortCodeOne = this.getField("BankSortCode-1");

                        var bankAccountNumber = this.getField("BankAccountNumber-1");

                        var effectiveDate = this.getField("EffectiveDate");

                        var ebdFields = [first, family, employeeNumber, bankName, bankAddressOne, bankAddressTwo, bankPostcodeOne, bankSortCodeOne, bankAccountNumber, effectiveDate ];

                       

                        //Check required fields for completion and visibility

                        for (var i in ebdFields)

                        {

                        if (ebdFields[i].display == display.visible)

                        {

                        this.EBDfieldCount++;

                        if (ebdFields[i].value != "")

                        {

                        this.EBDnumComplete++;

                        }

                        }

                        }

                       

                        var t = this.getField("EmployeeBankDetails");

                        if (EBDnumComplete == 0)

                        {

                        t.fillColor = this.gray;

                        }

                        else if (EBDnumComplete < EBDfieldCount)

                        {

                        t.fillColor = this.amber;

                        }

                        else

                        {

                        t.fillColor = this.green;

                        }

                       

                        this.getField("EBDProgress").value = this.EBDnumComplete + "/" + this.EBDfieldCount;

                        if (this.EBDnumComplete == this.EBDfieldCount) this.getField("EBDProgress").userName = "Done";

                        else this.getField("EBDProgress").userName = "";

                      }

                       

                       

                      ///

                      //Updates the Baseline Personnel Security Standard entry.

                      ///

                      /*----------------NEW-------------------*/

                      function BPSSupdate()

                      {

                        this.BPSSfieldCount = 0

                        this.BPSSnumComplete = 0;

                       

                        //Get all required fields in the form -----------

                        var first = this.getField("FirstName");

                        var family = this.getField("FamilyName");

                        var addressOne = this.getField("AddressOne");

                        var addressTwo = this.getField("AddressTwo");

                        var postcodeOne = this.getField("Postcode-1");

                        var daytimeTelephone = this.getField("DaytimeTelephone");

                        var dobOne = this.getField("DOB-1");

                        var dobTwo = this.getField("DOB-2");

                        var dobThree = this.getField("DOB-3");

                        var dobFour = this.getField("DOB-4");

                        var dobFive = this.getField("DOB-5");

                        var dobSix = this.getField("DOB-6");

                        var dobSeven = this.getField("DOB-7");

                        var dobEight = this.getField("DOB-8");

                        var birthPlace = this.getField("PlaceOfBirth");

                        var birthNationality = this.getField("NationalityAtBirth");

                        var presentNationality = this.getField("PresentNationality");

                        var bpssFields = [first, family, addressOne, addressTwo, postcodeOne, daytimeTelephone, dobOne, dobTwo, dobThree, dobFour, dobFive, dobSix, dobSeven, dobEight, birthPlace, birthNationality, presentNationality];

                       

                        //Check required fields for completion and visibility

                        for (var i in bpssFields)

                        {

                        if (bpssFields[i].display == display.visible)

                        {

                        this.BPSSfieldCount++;

                        if (bpssFields[i].value != "")

                        {

                        this.BPSSnumComplete++;

                        }

                        }

                        }

                       

                        var t = this.getField("Baseline");

                        if (BPSSnumComplete == 0)

                        {

                        t.fillColor = this.gray;

                        }

                        else if (BPSSnumComplete < BPSSfieldCount)

                        {

                        t.fillColor = this.amber;

                        }

                        else

                        {

                        t.fillColor = this.green;

                        }

                       

                        this.getField("BPSSProgress").value = this.BPSSnumComplete + "/" + this.BPSSfieldCount;

                        if (this.BPSSnumComplete == this.BPSSfieldCount) this.getField("BPSSProgress").userName = "Done";

                        else this.getField("BPSSProgress").userName = "";

                      }

                      • 8. Re: JavaScript works in Pro but not Reader - NotAllowedError
                        try67 MVP & Adobe Community Professional

                        OK, now it's more clear. There's a built-in property of the Document object

                        called title, so you can't define your own property with that name

                        (especially not if you're trying to apply a Field object to it, as it is a

                        String).

                        • 9. Re: JavaScript works in Pro but not Reader - NotAllowedError
                          Bernd Alheit Adobe Community Professional & MVP

                           

                          this.title = this.getField("Title");

                           

                          Adobe Reader can't change the property title of the document.

                          • 10. Re: JavaScript works in Pro but not Reader - NotAllowedError
                            gkaiseril MVP & Adobe Community Professional

                            As noted "this.title" cannot be altered by Reader. See the "X" in the 4th box of the Quick Bar. The same holds true for this.info[Title].