conga and javascript

New Here ,
Nov 20, 2017

Copy link to clipboard

Copied

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.

TOPICS
Acrobat SDK and JavaScript, Windows

Views

480

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

conga and javascript

New Here ,
Nov 20, 2017

Copy link to clipboard

Copied

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.

TOPICS
Acrobat SDK and JavaScript, Windows

Views

481

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Nov 20, 2017 0
Adobe Community Professional ,
Nov 20, 2017

Copy link to clipboard

Copied

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?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 20, 2017 0
New Here ,
Nov 21, 2017

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 21, 2017 0
Adobe Community Professional ,
Nov 21, 2017

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 21, 2017 1
Adobe Community Professional ,
Nov 21, 2017

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 21, 2017 0
New Here ,
Nov 21, 2017

Copy link to clipboard

Copied

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 ?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 21, 2017 0
Adobe Community Professional ,
Nov 21, 2017

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 21, 2017 0
Adobe Community Professional ,
Nov 21, 2017

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 21, 2017 0
Adobe Community Professional ,
Nov 21, 2017

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 21, 2017 0
New Here ,
Nov 22, 2017

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 22, 2017 0
Adobe Community Professional ,
Nov 22, 2017

Copy link to clipboard

Copied

When is your function called?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 22, 2017 0
New Here ,
Nov 22, 2017

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 22, 2017 0
Adobe Community Professional ,
Nov 22, 2017

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 22, 2017 0
New Here ,
Nov 22, 2017

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 22, 2017 0
Adobe Community Professional ,
Nov 22, 2017

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 22, 2017 0
Adobe Community Professional ,
Nov 22, 2017

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 22, 2017 0