Document Generation
...
Design Studio
How to build a template (Word)
15 min
introduction this guide explains how to create a template using cloudfiles document generation the cloudfiles office add in allows you to build templates in microsoft word (docx) using hubspot data for this tutorial, we will use the deal object to create a sample purchase order purchase order template you will learn how to use the insert field , insert image , insert table , and insert condition actions to generate documents with data from hubspot records what to expect by the end of this tutorial, you will know how to create a docx template with fields mapped from hubspot insert text, image and table elements into a docx template use conditions to show or hide content based on logic preview and publishing document template to hubspot tutorial video the video below illustrates the process of creating a template using cloudfiles document generation product pre requisites install cloudfiles in hubspot cloudfiles is available on the app marketplace and can be installed using the standard app installation process check out https //help cloudfiles io/hubspot/installation guide for cloudfiles hubspot integration template builder setup the cloudfiles add in connects with your hubspot org to enable template creation using hubspot data it can be instal led in led in microsoft word, excel or powerpoint microsoft word, excel or powerpoint , a llowing you to design templates directly for installation steps, see docid\ jihoktak7sipfqeppnmju stages of document generation document generation includes 3 main stages build preview publish after logging in to hubspot through the cloudfiles add in, set hubspot as the platform and select the deal object from the dropdown in this tutorial, we will use the deal object to create a sample purchase order template why use a purchase order template? a purchase order is a common document used to confirm and track product or service purchases it generally includes the deal details, account information, shipping details and a list of items generally includes the deal details, account information, shipping details and a list of items in this tutorial, we use the deals object in hubspot, which contains all the required details for generating the document for item level information, we will use the line items line items object, which holds product names, quantities, prices, and totals used to populate tables in the template we have created a sample purchase order template with placeholder fields for reference (see screenshot below) in the build stage, we will show how to use each action insert field , insert image , insert table , insert link and insert condition , to replace those placeholders with actual merge fields from hubspot after installing the cloudfiles add in and setting up for hubspot, you can use the template actions to insert fields and tables from hubspot data into the document stage 1 build 1 global variable when building templates, you work with global variables that help you pull in hubspot data the most common one is $record , which refers to the record you’re generating the document for — for example, a deal in this case using this, you can easily bring in fields like dealname, effectivedate , and related account fields 2 insert field insert the following fields into the purchase order template effectivedate – {!$record closedate} dealname – {{!$record dealname}} accname – {{!associated company name}} billingstreet – {{!associated company address}} you can similarly insert other fields such as shippingcity , region , website etc cloudfiles supports formatting for generated data such as text, dates, numbers learn more in docid 8hytvqidqjumncf2zomet note ensure that the integration user has the necessary permissions to access the fields being inserted if the required access is missing, the fields will not be available for use in the template 3 insert picture use insert picture action to add an image to the template this is ideally used for company logos, product images, etc place the cursor where the image should appear in the document, then select the insert picture action choose a field that contains a valid image url, such as a logo url stored in the account record you can also adjust the size of the image in the purchase order template, insert the field hs logo url from the account object, which holds the image url image {!associated company hs logo url} 4 insert link use insert link to add clickable urls from hubspot fields into your template in the purchase order template, insert the field website from the account object, which holds the url of the website website – {!associated company website} this will generate a working hyperlink in the final generated document 5 insert table use insert table action to include repeatable rows for lists, such as line items or products before adding a table, create a docid\ d4biogeef7uoj7eiznung with object set to ' line items ' which is typically used to represent the line items associated with the deals (e g , products purchased, quantities, and pricing) now, the record collection line items contains the products of the deal to configure the table, follow the steps below place the cursor on the template and select the insert table action in the resource type field, select the collection line items you created specify the required number of columns and rows add column labels for item , quantity , unit price , and subtotal in the first row place the cursor on the second row and use the , then click ‘make data row’ to include the values of the collection insert the following into the table from the collection line items using the insert field action product name {!line items name} quantity {!line items quantity} unit price {!line items price} total price {!line items amount} you can insert multiple fields into the same cell make sure you insert all the collection fields inside the data row 6 insert condition use to show or hide sections based on values from your record in the purchase order template, let's display a message only when the total order amount exceeds $10,000 steps to insert a condition place the cursor where you want the conditional content to appear open the cloudfiles add in and choose insert condition in the field dropdown, select the relevant field (e g , totalamount or order total) set the operator (e g , greater than) and enter the value (e g , 10000) click insert add the message inside < if > to display if the condition is met 7 document title if no document title is specified, the document will default to the name of the template global constants global constants are predefined values that remain the same for every document by default, the template includes $globalconstant emptystring – blank text value $globalconstant false – boolean false $globalconstant true – boolean true these constants can be used to add fixed values or control logic stage 2 preview the preview feature allows you to test how your document will look using real data before publishing it how it works enter a valid record id (e g , a hubspot deal id) into the input box click generate preview cloudfiles will populate the template with actual values from the record, showing you exactly how the final document will appear errors at preview in the preview section, if the template has any issues, you may encounter errors, such as 'preview generation failed,' along with a description of the error these errors typically indicate problems like malformed queries, etc make sure to review the error message and correct the issue accordingly before publishing stage 3 publish once you’ve finished building and previewing your template, use the publish step to save it for use in your hubspot org publishing options 1 publish as a new template choose this if you're creating a template from scratch enter a unique template name in the input field this will create a new version that will be available for use 2 select an existing template choose this option to update or replace a previously published template select from the list of available templates in the dropdown your current design will overwrite the selected template with the new version once published, the template will be listed in cloudfiles web app under the document generation tab → templates
