15 Replies Latest reply on Nov 22, 2017 10:17 AM by Joel_Geraci

    conga and javascript

    Brij12345

      hello,

      I have conga updating fields on the my pdf template.  After conga, the JavaScript on the template should execute on the conga updates.

       

      Conga will update 3 check boxes and the java script should use the conga updates to update the 3 check boxes.

        • 1. Re: conga and javascript
          Thom Parker Adobe Community Professional

          JavaScript executes in response to an event, and only in a viewer with an enabled JavaScript engine. So, what is the exact process for this update? And where is this JavaScript located?

          • 2. Re: conga and javascript
            Brij12345 Level 1

            Hello thom,

             

            For example,

             

            i have 2 checkboxes: checkbox1 and checkbox2

             

            conga will update checkbox1 after conga updated checkbox1, the JavaScript should update checkbox2.

             

            i have put the Javascript in a text field in the template in the calculate section (personalised script) for the textbox.

            • 3. Re: conga and javascript
              Joel_Geraci Adobe Community Professional

              You're probably going to need to add "this.calculateNow();" to a document level script so that the form will recalculate field values when it's first opened.  As Thom said, without an event to trigger the JavaScript, it won't run. That said, since you're using Conga, your appearance of your PDF won't be reliable unless your recipients open it in a JavaScript capable viewer. Most are not.

              • 4. Re: conga and javascript
                Thom Parker Adobe Community Professional

                The viewer is very important here.  Does the viewer where the Conga update happens support JS? If not, then as Joel points out, you'll need to force the script when the user opens the PDF in a viewer that does support JS.

                • 5. Re: conga and javascript
                  Brij12345 Level 1

                  Hello,

                   

                  Thank you for your responses.

                   

                  'you'll need to force the script when the user opens the PDF in a viewer that does support JS.'

                   

                  How can i do that ?

                  • 6. Re: conga and javascript
                    Joel_Geraci Adobe Community Professional

                    Conga isn't a viewer, it's a Salesforce integration that just pushes values into form fields on the server, no JavaScript, no appearance generation, it just jams in the value.

                    • 7. Re: conga and javascript
                      Joel_Geraci Adobe Community Professional

                      You can't control what viewer the recipient opens the PDF in. Basically, don't use Conga if you also need to have scripts run in your PDF.

                       

                      Alternatively, you can license the Datalogics PDF Java Toolkit (JT)... which can run JavaScript on a server just like Acrobat, and pass the Conga updated PDF to JT to recalculate and generate the proper appearances, then to your recipient.

                      • 8. Re: conga and javascript
                        Thom Parker Adobe Community Professional

                        I figured it was something like that, hence the question about process.

                         

                        So, there are a couple of ways to force the JS update when the form is opened in a viewer that executes JS.

                        1. As Joel mentioned, use the "this.calculateNow()" function in a document script. This function forces all the calculate scripts to execute

                         

                        or you could place the code that copies the values in a document script

                        • 9. Re: conga and javascript
                          Brij12345 Level 1

                          Hello,

                           

                          I have put the codes below in a document script:

                           

                          function updateFormula()

                          {

                              this.calculateNow();

                              var check1 = this.getField("Checkbox1").value;

                              var check2 = this.getField("Checkbox2").value;

                              var check3 = this.getField("Checkbox3").value;

                             

                              /*formula 1 checkbox*/

                              if(check1 == "1" || check2 == "1" || check3 == "1"){

                                  this.getField("Formula1").value = "1";

                              }

                              else if(check1 == "2" || check2 == "2" || check3 == "2"){

                                  this.getField("Formula2").value = "2";

                              }

                              else if(check1 == "3" || check2 == "3" || check3== "3"){

                                  this.getField("Formula3").value = "3";

                              }

                          }

                           

                          Conga will update Checkbox1, Checkbox2 and Checkbox3.  After the conga update, the javascript should execute to and update Formula1 or Formula2 or Formula3.

                           

                          I have put the 'calculateNow()' notation but it still doe not work.

                           

                          Please help

                          • 10. Re: conga and javascript
                            Joel_Geraci Adobe Community Professional

                            When is your function called?

                            • 11. Re: conga and javascript
                              Brij12345 Level 1

                              I have just put it in the Document Script.

                               

                              It should trigger after Conga (last process)

                               

                              i am new to adobe pdf JavaScripting.

                               

                              How can you decide when to run?

                               

                              i tried using the following:

                              -event.value

                              -event.target

                              -event.target.value

                              but nothing worked

                              • 12. Re: conga and javascript
                                Thom Parker Adobe Community Professional

                                The Document scripts are executed when the PDF is opened in Acrobat/Reader, or any viewer that runs JS.  However, running the script you posted above simply defines a function, the function has to be run for this all to work.

                                 

                                The easy thing to do is to just call it at the end of the scirpt, i.e. add this line to the bottom.

                                 

                                updateFormula();

                                 

                                Now, let's clean it up.  Since this function is updating the fields, there is no reason to include the "this.calculateNow()" function. By the same token, you also don't need the calculate scripts that update fields.

                                 

                                Do you need the "formula" fields to update when the user clicks on the check boxes?  If so then add this function call to the "MouseUp" scripts for each checkbox.

                                • 13. Re: conga and javascript
                                  Brij12345 Level 1

                                  Hello,

                                   

                                  I removed the 'calculateNow()' line in the script and added the function call at the buttom.

                                   

                                  It worked fine when the pdf is displayed on the browser and when downloaded.  Thank you for this part.

                                   

                                  The issue now is that it does not work on Universign.

                                  • 14. Re: conga and javascript
                                    Thom Parker Adobe Community Professional

                                    Probably not.  At least not the mobile version. If it works at all depends on the PDF library/engine they are using, which they don't say on their web page.

                                    • 15. Re: conga and javascript
                                      Joel_Geraci Adobe Community Professional

                                      I'll go back to my previous recommendation. You're going to need to process the JavaScript on a server before your PDF will be reliable on all of the various viewers out there.