8 Replies Latest reply on Aug 28, 2014 4:49 PM by MichaelN

    Audit guide tally and auto-calculation

    MarkCoulombe

      Hi,

      I have been trying to figure out how to take a PDF audit guide and make it clickable from tablet and auto-calculate results.

      On the right margin, there is "yes" or "no" blocks for individual check items being satisfied or not (sometimes an item may be N/A).

      I would like to create check boxes that somehow tally the yes vs no checks and provides a percentage in one of the seven sections (picture attached).

      Then finally, a cumulative grade and a status range (ie: status-1 is >90%, status-2 is >80% but less than 90%...)

       

      So, what I tried already was to make my check boxes. I then inserted a text box --> properties --> calculate --> value is the "sum", and I picked all the check boxes in a given section. I don't see how it would differentiate my "yes" vs "no" and likely requires a custom calculation script. I reviewed some of the posts and the script is well beyond my level of knowledge. I appreciate any assistance or direction that can be provided. Thanks.Capture.PNG

      OK, I thought of two more questions. I would greatly appreciate a solution to the top one but any would be progress...

      I created inter-document links that send users to a cited reference point. How do I get them back to the audit guide section they left? All the navigation features seem to be "Next, Last, Previous, First".

      Lastly, I would like to have discrepancy comments entered as they are identified. Should I even try to incorporate this into a PDF reference/audit guide or keep separate? If incorporated, it would be expected that some report/page could show all collective comments. Thanks again :-)

        • 1. Re: Audit guide tally and auto-calculation
          gkaiseril MVP & Adobe Community Professional


          Have you looked at any forms that perform calculations?

           

          One can only sum numeric values. One can count fields and make a selection by the value using an "if" statement. These scripts will require custom JavaScript calculations.

           

          Percentage calculations will require a description of how you exactly want the calculation to be computed.

          • 2. Re: Audit guide tally and auto-calculation
            MarkCoulombe Level 1

            I have not found any forms that perform calculations that are similar to what I am trying to accomplish.

             

            I anticipated the need for custom scripts to accomplish my goal. I took a scripting class once but it was utilizing very basic concepts and visual operators. I still cannot script...

             

            As for the percentage calculation, I think I may be able to teach myself this one unless incorporated into some large script. I would assume that I just sum blocks A - G in the attached graphic above and divide by 7 since they are all weighted the same. As for the status code, it is not that important that I get it to auto populate. The numeric grade would suffice.

             

            So, my take away is that I need to find an "if" script to tally yes vs no responses and incorporate N/A response when encountered. Then Sum of sections to achieve final grade which seems like it could be accomplished with a simple equation.

             

            Please let me know if I am on point and where I should seek out the specifics for scripting. Thanks.

            • 3. Re: Audit guide tally and auto-calculation
              MichaelN Level 3

              This script should get you started.

               

              It will count the number of "Yes" and "No" radio button or check box responses.

               

              First create 7 radio button pairs for "Yes" and "No". Make sure their export values are either "Yes" or "No".

               

              Then create a text field to show the "Yes" responses and have this as its custom calculation script:

               

              //Create an array to hold all Yes responses

              var selectedFields = [];

                   for (var i=0; i<this.numFields; i++) {

                   var f= this.getField(this.getNthFieldName(i));

              //Search for all ticked Yes radio buttons

                   if (f.value=="Yes" && f.type=="radiobutton"){   //or "No" to count the No responses, and change "radiobutton" to "checkbox" if counting check boxes

              //Add them to the array

              selectedFields.push(f.name);}

              }

              //Make the value of the Yes text field equal the number in the array

              event.value = selectedFields.length;


              You will have to create another text field to count the "No" responses, with line 6 of the script changed to:

               

              if (f.value=="No" && f.type=="radiobutton"){

               

              You can do something similar with check boxes, but with type=="checkbox" in line 6 of the script.

              • 4. Re: Audit guide tally and auto-calculation
                George_Johnson MVP & Adobe Community Professional

                If you need to do this on a tablet, you have to specify which OS and which PDF viewer you're using. Many PDF viewers on tablets have no support for JavaScript, others have very limited support, and other have pretty good support. The only ones that I know that would support all that Michael posted are PDF Expert on iOS and qPDF Notes on Android.

                • 5. Re: Audit guide tally and auto-calculation
                  try67 MVP & Adobe Community Professional

                  This line of code will throw an error if you have any buttons in your file:

                  if (f.value=="No" && f.type=="radiobutton"){

                   

                  You need to change the order of the conditions for it to work correctly.

                  • 6. Re: Audit guide tally and auto-calculation
                    MarkCoulombe Level 1

                    Michael, thank you very much. I admittedly cannot write code and comprehend the syntax, but I can look at your work and understand what is happening. The biggest part of the challenge of at least performing a tally is done and now I can introduce more simplistic equations to start forming individual section grades and a total numeric grade... More within my capability;-)

                    My hat is off to you all that can put this code together so quickly to support me and the other 5000+ community members seeking help. Thanks!

                    • 7. Re: Audit guide tally and auto-calculation
                      MarkCoulombe Level 1

                      Uh oh, spoke a little too soon. As I started working this, I did note an issue. The "ALL" part of the script is not allowing me to tally individual section grades. I created the text box and added the script for YES and NO. Now I cannot add a similar tally for the next individual section. Is there a scripting term I can add in place of ALL to allow me to tally YES and NO responses within a parameter/audit section in my case?

                      Capture.PNG

                      • 8. Re: Audit guide tally and auto-calculation
                        MichaelN Level 3

                        I'm not sure what you mean by "ALL" part of the script, but I think the problem may be because you have used the same script for all your categories.


                        I assume you have separate checkboxes for "General Administration", "Training", "Medical Readiness", etc.


                        The script provided earlier declares certain variables such as "selectedFields" and "f", and gives those variables a value.


                        Every time you declare a variable, it re-sets the previous value, so you need to have unique variable names for your different categories.


                        For example, for "Training" you could use:

                         

                        "Training_selectedFields" (in line 2)

                        "g" (in lines 4, 6 and 8)

                         

                        and so on for each of your categories.

                        Having unique variable names avoids the problem of variable values "overriding" other variable values that were declared earlier.


                        You should also use Gilad's suggestion in Post no.5.