Using arrays in the pdfmonkey integration

Ok I have done that like in the Jobs table like this:

08723-22 Jamal Abraham 4.02, 08723-22 Brian Peterson 0.00, 08723-22 Carl Bailey 10.02

Then I assume you also have a separate table with unique job rows, or no?

Yes a separate table for Jobs with unique rows. I have connected the filtered timecards to the connected job row and pulled in the html for each job.

Then can you tell me what is not working?

Not sure in the code here to place the generated HTML.

I have a near identical use case with PDFMonkey. All of this makes sense to me, but it’s unclear to me where I should construct the table portion in Glide? It doesn’t appear that I can do this in a TEMPLATE column, because the TEMPLATE column can’t reference relations.

Where/how do I construct the HTML so that I can pass it to PDFMonkey.

Relations exist as a “pathway” to that row of data, it doesn’t bring you direct data.

To retrieve data, you use the lookup/joined list column and configure further from there.

The ideal way to do this with PDFMonkey is:

  • Creating a loop in PDFMonkey to display your table. There’s an actual example of a table here: Iteration (dealing with lists) | PDFMonkey

  • In Glide, create a JSON object column for each row of data in lineItems.

  • On the parent level, use a relation and joined list column to get all JSON object backs, separated by a comma and a newline character (for easy viewing).

  • Add a template column:

[
J
]

With J being the joined list column above to finish configuring the array structure correctly in Glide.

  • Add a PDFMonkey integration, specify your template ID and variables, including the lineItems thing above.

  • Glide will pass the lineItems thing as text, you have to add a step to parse it. Let’s say the parsed variable is parsedLineItems.

{% assign parsed_lineItems = lineItems | parse_json %}

{% for item in parsed_lineItems %}
    <tr>
      <td>{{item.product}}</td>
      <td>{{item.quantity}}</td>
      <td>${{item.price | with_delimiter, precision: 2}}</td>
      <td>${{item.price | times: item.quantity | with_delimiter, precision: 2}}</td>
    </tr>
  {% endfor %}
1 Like

Thank you! That was the missing piece I needed! Thank you so much!

Yes, but make sure you do this. Glide has always sent JSON arrays to PDFMonkey as text so we need this extra step.

1 Like

Success! Thank you! It works perfectly!

1 Like