JSON from multiple tables to one table

Using HTML2PDF to create PDF from multiple tables in Free plan

In this example, we are using two tables to source data to display data for a single item in a PDF, namely, Animals and Medical, but you can include as many tables as you need. In Animals, there are rows of animals, but it is one row per animal. In Medical, there are rows of medical data of which there could be multiple rows for each animal. I’m not going into detail of how to create and link these tables as it is assumed you have this basic knowledge. We are also using a Helper table called Helper.

Step 1

In the Medical table, assuming you want to grab the data relating to date, practitioner, reason and details, create a template column called HTML_MedicalTable using replacements to dynamically add all the values. Please see Figure 1 in Appendix for an example.

Step 2

Create a Helper table which is just a regular table. In this example it is called HELPER_PDF. This is the table that will do all the grunt work grabbing the necessary information for a singular animal, temporarily holding the data in one temporary row only so the PDF can be generated and then deleting it. Create the following columns within the Helper table:

  • Animal ID (Text)
  • Rel Animals (Relation using the Animal ID)
  • Animal Name (Lookup using the relationship)
  • Query Medical (Query using the source of Medical and filtering by This Row>Animal_ID and ensuring you have ticked allowing multiple matches – see Figure 2 in Appendix for an example)
  • Joined List Medical (Joined List using the texts in Query Medical, HTML_MedicalTable. Please ensure that there is NO separator in the “Separated by” field)
  • HTML (Template with the necessary HTML and Replacements – see Figure 3 in Appendix for an example)
  • HTML2PDF (Construct URL with the necessary configuration as shown in Figure 4 in Appendix. Please note that you can use a different link to the HTML2PDF PDFWizard, as outlined here)

Step 3

Next you need to create an App Interaction workflow using the Animals table as the Data Source. Called it “Print PDF Button” and configure it to allow three steps to happen when the button is pressed (which will be created in Step 4). The workflow has three steps, namely:

  • Add a new row to the HELPER_PDF table based on the Animal ID.
  • Open a link which is defined in the HELPER_PDF HTML2PDF column.
  • Delete the row that was created in the HELPER_PDF table.

Please see Figure 5 in the Appendix for an example.

Step 4

The final step is to create the button that will trigger the workflow for the preloaded animal. Because of this, I created the button on the Details screen for the individual animal (which I get to by clicking on the animal from the Collection of animals). I made my button in the Title component since there is a button there for Edit already so it made sense to also have a button to print the PDF. Again, this can be done wherever you see fit providing it is looking at one animal only.

In the Title component, in the Actions section within the General tab, add an action and configure it to call the “Print PDF Button” workflow created in Step 3. Call the action “Print PDF”. Please see Figure 6 in the Appendix for an example.

Appendix


Figure 1


Figure 2


Figure 3


Figure 4


Figure 5


Figure 6

Handy Links

4 Likes