6 Replies Latest reply on Jan 12, 2013 11:13 AM by axdeems

    help with a custome scripts

    axdeems

      Hello! I'm going crazy trying but i wasnt able to figure this out

      My A box is the number of accounts  ( actual number 312 ) this box is a fix number and does not change

      My B box is the accounts remaining for the year

      My C box is the accounts completed during the year

       

      And up to that point i think im ok im using this for the simple math

      // Get first field value

      var v1 = getField("A").value;

       

      // Get second field value

      var v2 = getField("C").value;

       

      // Set this field value equal to the difference

      event.value = v1 - v2;

       

      Here is my issue  i need to provide a persentage of whats been done but how?  It need to be from 0 to 100% example if we completed 156 the % box should display 50% and when all are completed to be at 100%

       

      My D changes every week and i dont think this has a solution but since im not sure i'll ask ( d ) box changes every week and we do the math and make the changes  on box c..... ok my question is there any way box d auto add the number type into box c and if i were to delete the number type on d will nop subtract box c *** if that can be done please how???

      Acrobat.png

        • 1. Re: help with a custome scripts
          gkaiseril MVP & Adobe Community Professional

          Custom script for the % completed field

           

          // Get total accounts for the year

          var v1 = Number(this.getField("A").value);

          // Get completed accounts for the year

          var v2 = Number(thi.getField("C").value);

          // compute the rate of accounts completed

          var CompletionRate = 0;

          // do not divide by zero

          if(v1 != 0) {

          CompletionRate = v2 / v1;

          }

          event.value = CompletionRate;

           

          Set the format for the field to "Percentage" with 0 decimal places.

          • 2. Re: help with a custome scripts
            axdeems Level 1

            I try just to copy paste but dint work any susgestions ?

            • 3. Re: help with a custome scripts
              gkaiseril MVP & Adobe Community Professional

              Are your sure your field names are correct?

               

              Are there any errors in the JavaScript console?

              • 4. Re: help with a custome scripts
                axdeems Level 1

                The names are correct and i didnt get any errors! When i copy paste the formula on the custom calculation scripts

                 

                // Get total accounts for the year

                var v1 = Number(this.getField("grand").value);

                // Get completed accounts for the year

                var v2 = Number(thi.getField("completed").value);

                // compute the rate of accounts completed

                var CompletionRate = 0;

                // do not divide by zero

                if(v1 != 0) {

                CompletionRate = v2 / v1;

                }

                 

                 

                Thats the actual formula on the Percentage box

                • 5. Re: help with a custome scripts
                  gkaiseril MVP & Adobe Community Professional

                  You left out the setting of the event.value.

                   

                  console.show();

                  console.clear();

                  // Get total accounts for the year

                  var v1 = Number(this.getField("grand").value);

                  // Get completed accounts for the year

                  var v2 = Number(this.getField("completed").value);

                  // compute the rate of accounts completed

                  var CompletionRate = 0;

                  // do not divide by zero

                  if(v1 != 0) {

                  CompletionRate = v2 / v1;

                  }

                  event.value = CompletionRate;

                  console.println("grand value: " + v1);

                  console.println("completed value: " + v2);

                  console.println("% completed: " + util.printf("%,1 0.2f%", (CompletionRate * 100));

                  • 6. Re: help with a custome scripts
                    axdeems Level 1

                    It works...... Thank you so much   you really made my weekend thanks

                     

                    AX