Skip to main content
Known Participant
June 22, 2020
Question

Button to open new PDF and populate fields

  • June 22, 2020
  • 1 reply
  • 2119 views

I am guessing this is a 2 part question/answer:

 

1) I am looking to use a button to open a new pdf fillable form

2) When it opens that new form I want it to take the info on the form open and popluate certain fields

 

Is this possible?

This topic has been closed for replies.

1 reply

Joel Geraci
Inspiring
June 22, 2020

It's possible but there are better and worse ways of accomplishing this. Will the second form always be known to you? In other words are the two forms always associated with each other?

Known Participant
June 22, 2020

Yes both forms will always be used.  One is a quote form than when it needs to be updated to an other I wouild like the user to use the button to create an invoice that would auto populate with the needed fields.

Joel Geraci
Inspiring
June 22, 2020

Ok - Then you want to make the invoice template an attachment to the quote form. This will let you open it programmatically without a user being prompted to find the file on their hard drive and won't require a privileged context.  The code below will give you a handle to the invoice document.

var invoiceDoc = this.openDataObject("invoiceTemplate.pdf");

You will need to add some code at the document level of the invoiceTemplate to disclose it to other documents so you can send it JavaScript.

this.disclosed = true;

 From there it's just a matter of setting the field values.

invoiceDoc.getField("myField").value = this.getField("myField").value

 Then you'll want to add some code to save the file.