In this guide, we will explain how you can display the Formyoula Salesforce Table field on PDF.
To start with, Drag and Drop a Salesforce Table" from the Tab “Salesforce” under “Drag and Drop Fields” on your form. And select the Salesforce object and fields which you want to display on the form and PDF.
As per the above image I want to show the Name, Billing City, Billing State and Billing Street on the PDF.
Click Apply Changes and Save the form.
Now we need to do some settings in the PDF source, so to do that we need to open the PDF editor from the dashboard by clicking the PDF Editor from the actions.
Now we need to Enable the Custom PDF Template option on the PDF Editor.
Now we need to select the Salesforce component-id / merge-id from Merge Fields. Or you can copy the field id from the Salesforce field.
Now we Just need to click on “Source” from the PDF editor.
And use the {{#each }} block to render all the row data of the Salesforce table.
<!-- {{#each 814f-1c4c-de38}} -->
Name :<strong>{{Name}}</strong><br />
Billing City : <strong>{{BillingCity}}</strong><br />
Billing State <strong>{{BillingState}}</strong><br />
Billing Street:<strong>{{BillingStreet}}</strong><br />
<!-- {{/each}} -->
Example code: To show data in horizontal table view in pdf -1
<style>
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;
}
td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
tr:nth-child(even) {
background-color: #dddddd;
}
</style>
</head>
<body>
<h2>HTML Table</h2>
<table>
<tr>
<th>Name</th>
<th>Billing City</th>
<th>Billing State</th>
<th>Billing Street</th>
</tr>
<!-- {{#each 814f-1c4c-de38}} -->
<tr>
<td>{{Name}}</td>
<td>{{BillingCity}}</td>
<td>{{BillingState}}</td>
<td>{{BillingStreet}}</td>
</tr>
<!-- {{/each}} -->
</table>
Example code: To show data in horizontal table view in pdf -2
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
</style>
<table style="width:100%">
<tr>
<th>Name</th>
<th>Billing City</th>
<th>Billing State</th>
<th>Billing Street</th>
</tr>
<!-- {{#each 814f-1c4c-de38}} -->
<tr>
<td>{{Name}}</td>
<td>{{BillingCity}}</td>
<td>{{BillingState}}</td>
<td>{{BillingStreet}}</td>
</tr>
<!-- {{/each}} -->
</table>
Now we just need to “Enable Advanced Templating” option from PDF Editor Page Settings.
This will show the Salesforce Table data on PDF.
For any questions, please contact us - [email protected] or the Formyoula in-app chat 🙂