Create a Products Table

info

The HubSpot (BETA) integration will be receiving continuing development. Please send us your feedback on the integration and what you would like to see added in the future at hubfeedback@windward.net.

A Dynamic Table of Line Items for the Deal#

While your template should not have dynamic data for the invoice and shipping addresses, all of this data only outputs once. What if you want to have a single piece of your template output multiple times? Specifically, this tutorial will learn how to make a table where rows are repeated for each Line Item associated to your deal.

Inserting a ForEach Tag#

A ForEach Tag is a tool in the Windward Designer that let's you loop over multiple records of data. For each record (get it, "ForEach") you can repeat a piece of content in the template. You could add items to a list, output entire paragraphs and other content, repeat whole pages (or more), or, in the case of this tutorial, repeat a row in a table for multiple records.

  1. Place your cursor after the first table in your template and click the "Return" key to go to a new line. img
  2. With your cursor on the new line, insert another table. This time of dimensions 3X4. img
  3. In the first row of the table enter the titles "Products," "Unit Price," and "Total." These will be the columns in our output table. img
  4. Place your cursor in the cell bellow the "Products" title and in the Windward ribbon, click "Tags" -> "ForEach." img
  5. This is another way to insert a place holder in your template: the Out Tag is the placeholder you've used so far to output a single piece of data. The ForEach Tag will instead allow us to output multiple pieces of data. You'll see the new ForEach Tag in your template in orange: img
  6. This Tag doesn't have any data associated with it yet, but you can associate data to it using the Data Tree like you did earlier. Place your carrot directly on the ForEach Tag. You'll notice some buttons in the Windward ribbon that were greyed out before can now be clicked: img
  7. In the ribbon, click on "Data Tree" and click on the "Root Node" -> "associations" -> "line items" -> "results" img
    tip

    For a ForEach Tag, you should choose a node that can return multiple records. Then the output template will be able to output multiple sections of content for Each record. Nodes that return multiple records are indicated with blue brackets in the Data Tree, like the "line items" -> "results" node: img

  8. You can check to see if your ForEach Tag is returning the records you expect. Place your carrot on the ForEach Tag, and click "Review" in the Windward ribbon. You should see the Line Items for your Deal listed in the preview (you can explore the returned records to see the quantity, price, and other properties for each line item). img
  9. To make the purpose of your ForEach Tag more clear in the template you can update it's nickname. Place your carrot on the ForEach Tag and change the nickname under the Windward ribbon to "ForEachLineItem." img
  10. In the next step you'll use a variable for the ForEach Tag. To make the variable more clear, update the "Variable" field under the Windward ribbon to "lineItemLopVar." img

Outputting Repeating Data#

The ForEach Tag only loops over multiple records of data, it doesn't generate any output.

  1. Place your carrot after the ForEach Tag and click "Tags" -> "Out" to place a new Out Tag in the template. This will be the placeholder for some data at output. img
  2. Place your carrot on the new Out Tag and open the Data Tree from the Windward ribbon. You'll notice the Data Tree now has a variable with the variable name you specified for your ForEach Tag. img
  3. Expand the "${lineItemLoopVar}" variable and you will see a list of nodes. All of these nodes are accessible for each record returned by the ForEach.
  4. For this Out Tag, select the node "${lineItemLoopVar}" -> "properties" -> "product" -> "properties" -> "name." This will output the name of the product associated with each line item. img
  5. Finally, you need to place an End ForEach Tag. All of the content between the ForEach Tag and the End ForEach Tag will be repeated for every record returned by the ForEach Tag. Since for this template you only want to repeat the one row of data, place the End ForEach Tag in the cell directly bellow the ForEach Tag. Place your cursor in the cell bellow the ForEach Tag and click "Tags" -> "End ForEach" img
  6. The basis for your product table is now complete! Generate output and if everything is working properly you should see a line in the output table for each Line Item on the Deal in HubSpot img
tip

Only seeing one product name in the output table?#

If your deal in HubSpot only has one Line Item in the Deal you will only see one Line Item in the output table. To try outputting with a deal that has multiple Line Items, find a good example deal and update the Unique ID for the deal in the Connection String.

You can remind yourself how to do this here.

Finish the Table#

To finish your table, just add the remaining tags to output a full table of line items:

  1. On a new line under the ForEach Tag and Out Tag enter the text "Quantity:" and insert an Out Tag. Associate the Out Tag to the "${lineItemLoopVar}" -> "properties" -> "quantity" using the Data Tree. img
  2. In the cell under "Unit Price" insert an Out Tag. Associate the Out Tag to the "${lineItemLoopVar}" -> "properties" -> "price" using the Data Tree. img
  3. In the cell under "Total" insert an Out Tag. Associate the Out Tag to the "${lineItemLoopVar}" -> "properties" -> "amount" using the Data Tree. img
  4. Generate test output to see this repeated data appearing at output: img

Conclusion#

Your output is finished, but (and no offence...) it doesn't look very good yet! In the next step of the tutorial you'll learn how to take your current quote to the next level with:

  • Formatting dollar values as currency
  • Adding the total quote amount
  • Adding a quote date
  • Improved table formatting
  • And a custom header