Skip to main content
cherylminor85
Participant
Feb 17, 2017 4:04 PM UTC
Question

Fillable Form from Dataset

I have been tasked with the process of altering a fillable pdf form at work. The purpose of this form is for an employee here at the office to run this application and to select a proposal and it populate a list of classifications and wage rates, save the pdf form and then they can email that form to users in the field to fill out and return.

I am not really that familiar with fillable pdf forms but as a programmer feel I can handle it. The form I am trying to populate contains three columns; a classification field that I populate with selected dropdown items (I found this easy) and then an Hourly Rate Paid column that I am trying to populate dynamically when they select a classification and a number of employees column that they enter manually.

What I need the form to do is when a classification is selected from the dropdown (by the user in the field) the form is supposed to look through a dataset of some type and find that classification along with its related wage rate and then automatically populate the hourly rate paid. Everything I have read says if the users using the form aren't local then using a database isn't the best option. So, I thought on the original generating of the fillable pdf form, by the employee in the office, that I could query the database, store the data locally some how whether a dataset or a temp table or something and then when the user in the field gets the form and selects a classification that it uses that local table/dataset to find that value.

I am able to create a temp table in the vb code of the application but have no idea how to call that table within the javascript editor.

Here is the function I wrote for pulling the data into a local table

Private Function Classifications_values(ByVal classifications As List(Of Model.V_WAGE_DECISIONS))

        Dim classification_value As New DataTable

        classification_value.Columns.Add("Classification")

        classification_value.Columns.Add("Value")

        For Each i In classifications

            Dim itm As Model.V_WAGE_DECISIONS = i

            Dim row As DataRow = classification_value.NewRow

            row(0) = i.DESCR

            row(1) = i.WAGE_RATE

            classification_value.Rows.Add(row)

        Next

        Dim ds As New DataSet

        ds.Tables.Add(classification_value)

        Return ds

    End Function

And in javascript of the pdf form I set up a document JavaScript called SetFieldValues and did this:

function SetFieldValues(classification)

{

this.getField("Hourly Rate Paid").value = classification_value[classification].Value;

}

If I replace "classification_value[classification].Value" with the number 12 it works perfectly but it won't query the table/dataset.

Any suggestions would be appreciated. Thanks!

This topic is closed to new replies. Start a new post to keep the conversation going.

4 replies

Bernd Alheit
Community Expert
Community Expert
Feb 17, 2017 5:21 PM UTC

Acrobat JavaScript can't access the table in the VB code.

Translate
try67
Community Expert
Community Expert
Feb 17, 2017 5:21 PM UTC

First of all, I moved your question to the JavaScript , where it more naturally belongs.

Regarding your question: Connecting an Acrobat form to a DB, local or otherwise, is impossible.

The data will have to be embedded in the file itself (in the form of a plain-text file, for example), or read dynamically from a local (also plain-text) file. The latter option requires installing a script on the local machine of each user, as well as the data file itself, so it's probably a less desired solution.

If the data is attached to the file then a script can be used to read it, parse it and then populate the other fields when a selection is made in one of the drop-downs. This is a pretty advanced scripting task, though, and requires you to be familiar with data objects (the technical name for attachments), string manipulation and field-triggered scripts.

Translate
cherylminor85
Participant
Feb 17, 2017 6:43 PM UTC

Thank you for putting me in the right place. I wasn't 100% sure where to post. I appreciate that.

This leads me in a general direction which is what I really needed. I will do some more digging into parsing a plain-text file and see if I can get it figured out. If not, I may go another direction with it! Thanks!

Translate