How to Show Different Tables in Salesforce Documents

Category :
How To

Published: June 30, 2026

Docs shouldn’t be complicated.

With Docs Made Easy, creating professional, Salesforce-powered documents is just a few clicks away.

Get Started Now

In Salesforce document generation, displaying the right data in the right format can become difficult when different conditions exist in a record. For example, if Account Rating is not handled properly, users may end up generating the wrong table or manually editing documents every time, which increases effort and the chances of errors.

To solve this, IF conditions can be used inside Word templates to automatically control which table is shown based on Salesforce field values. This ensures documents are always accurate, dynamic, and aligned with business rules.

Let’s now look at how this can be implemented step by step.

Steps to Create Conditional Tables in Salesforce Document Generation 

To show this use case, we have created two table formats based on the Account Rating field. One table includes full contact details, while the other shows a simpler version with only key information.

Table one:

First Name Last Name Contact no.
{{TableStart:Account.r.Contacts}}{{FirstName}} {{LastName}} {{Phone}}{{TableEnd:Account.r.Contacts}}


With three columns: First Name, Last Name, and Contact Number.

Table two:

Last Name Contact no.
{{TableStart:Account.r.Contacts}}{{FirstName}} {{Phone}}{{TableEnd:Account.r.Contacts}}

 

With only two columns: LastName and Contact number.

Step 1: Open your document in the template editor (here we are using MS Word) where you want to apply conditional logic for table rendering.

Step 2: Now go to the Insert tab in the menu, click on Quick Parts, and then select Field from the available options.


Step 3:
Now select IF Expression from the list of fields and click on OK to insert it into your template.


Step 4:
You will now see the condition field inserted in your document. Click on Toggle Field Codes to edit the logic.


Step 5:
In the condition field, define your logic using the Salesforce merge field. For example:
“{{Account.Rating}}” = “Hot” → Paste Table 1
Otherwise → Paste Table 2 or leave blank

This condition ensures that if Account Rating is Hot, Table 1 will be displayed, otherwise Table 2 will be rendered.


Step 6:
If required, you can insert another conditional field and define additional conditions based on different rating values.


Step 7:
Once your logic is properly defined, click on Update Field to apply changes.


Step 8:
Save the template and add it to your document generation solution.

Step 9: Generate the document using a Salesforce record.

If the record has rating Warm, Table 2 will be shown.

  • If the record has rating Hot, Table 1 will be displayed.


Conclusion

Conditional tables in Salesforce document generation make it easier to handle different data scenarios without creating multiple templates. Once the IF logic is set up correctly, the document automatically picks the right table based on the record value, so you don’t need to adjust anything manually each time.

This approach keeps your templates clean and easier to manage over time, especially when business rules change or new conditions are added.

We hope this helps you set up IF conditions in a simple way and makes your document generation process more efficient in real use.

 

Frequently Asked Questions

Conditional tables reduce manual edits by displaying only relevant information. Using Salesforce document generation with Docs Made Easy helps generate accurate Salesforce documents while minimizing formatting and data errors.
Automating document generation saves time, reduces repetitive tasks, and improves consistency. With Docs Made Easy, teams can generate professional Salesforce documents faster while following standardized business processes.
Yes. Sales, finance, HR, and legal teams can use Salesforce document generation to create customized documents. Docs Made Easy enables every department to automate documents using the same Salesforce data.
Automated document generation eliminates copying, pasting, and formatting data manually. By using Docs Made Easy, businesses can create error-free Salesforce documents directly from Salesforce records in minutes.
Yes. Automated Salesforce document generation ensures logos, layouts, and formatting remain consistent. Businesses using Docs Made Easy can generate branded Salesforce documents without manually updating every template.

Related Blogs


How To

How to Create a Document Solutions Collection in Salesforce

Managing multiple document templates can be challenging when users need quick access to different solutions from a single location. Document…

Read more
How To

Data Routing: How to dynamically select templates using formula fields (Part 1)

Many organizations need different documents at different stages of the sales cycle. Manually selecting the correct document template for every…

Read more
How To

How to Create a Static Resource in Salesforce for Document Generation

Creating static resources in Salesforce is important when you need to store reusable files like images, text files, or HTML…

Read more