Help Center Conditional Logic Show or Hide Sections

Show or Hide Document Sections Based on Salesforce Fields

Updated June 2026 8 min read Conditional Logic
Show/hide is the most widely used conditional logic pattern in Dochly — controlling whether entire sections, clauses, paragraphs, or content blocks appear in the generated document based on Salesforce field values. This guide covers the mechanics of show vs hide, what can be conditionally controlled, conditions by field type, and a ready-to-use pattern library for the most common document scenarios.

Show vs hide — choosing the right action

When you apply a condition to an element, you choose whether the condition shows or hides the element when true. These two approaches produce the same result but suit different template design patterns — choosing the right one makes your conditions easier to read and maintain.

Show when true

Element is hidden by default — shown only when the condition passes

Use when: the section is optional — it only belongs in some documents.

Example: "Volume Discount Terms" is not shown unless Amount > 50,000. Default: hidden. Condition makes it visible for large deals.

Tip: Most conditional sections use this approach — content is off unless earned by the record data.

Hide when true

Element is shown by default — hidden only when the condition passes

Use when: the section belongs in most documents but should be suppressed in specific cases.

Example: "Standard Payment Terms" should be hidden when a Custom_Terms__c field is populated — replaced by the custom terms. Default: shown. Condition suppresses it when custom terms exist.

Tip: Use hide-when-true sparingly — show-when-true is generally easier to reason about.

When in doubt, use Show when true. It follows the principle that conditional content is "off by default" and only appears when the data warrants it — making your template logic predictable and easier to audit.


Scope — what you can show or hide

Show/hide conditions can be applied at different levels of the document structure — from an entire page section down to a single inline sentence. The broader the scope, the simpler the template to maintain.

Section

An entire named section of the document — heading plus all body content. Best for large optional blocks like "Appendix A", "GDPR Terms", or "Premium Support SLA".

Paragraph

A single paragraph of body text. Use when only one clause or explanation should be conditional within a larger section that always appears.

Table

An entire table — header row and all data rows. Use when a whole data block (e.g. a pricing breakdown) should only appear for specific deal types.

Table row

A single row within a table. Use to filter individual line items — e.g. show only rows where a line item field meets a criterion. See Dynamic tables.

Image

A logo, diagram, or signature block image. Use when a visual element should only appear for certain customers — e.g. a partner logo only when Account.Type = "Partner".

Inline text

A word, phrase, or sentence within a paragraph. Use for small substitutions — e.g. showing "Exclusive" before "pricing" for VIP accounts. For longer inline branches, use if/else syntax instead.


How it looks in the document

The same template generating two different documents — one for an Enterprise account, one for a Standard account. The Enterprise-specific sections are shown on the left and absent on the right:

Template output — Enterprise (left) vs Standard (right)
Enterprise — Amount = £120,000
Always shown Agreement Terms and Conditions
Always shown Scope of Services
Shown Enterprise SLA — 99.9% uptime guarantee with 4-hour response time
Shown Volume Discount Terms — 15% applied to orders over £100,000
Always shown Payment Terms — Net 30
Shown Dedicated Account Manager — included with Enterprise tier
Always shown Governing Law and Jurisdiction
Standard — Amount = £8,500
Always shown Agreement Terms and Conditions
Always shown Scope of Services
Always shown Payment Terms — Net 30
Always shown Governing Law and Jurisdiction

When a section is hidden, it is completely removed from the generated document — no blank space, no placeholder, no visible indicator that a section was conditional. The surrounding content flows together as if the section was never there.


Conditions by field type

The right condition syntax varies by Salesforce field type. Here is how to write show/hide conditions for the most common field types:

Picklist

Picklist / Select

StageName = "Closed Won"
Use the equals operator with the exact picklist label value. Case-sensitive — "Closed Won" ≠ "closed won". Always copy the value from the Salesforce picklist definition to avoid typos.
Checkbox

Checkbox / Boolean

Is_Renewal__c is true
Use is true or is false operators. Do not use equals with "true" as a string — use the dedicated boolean operators which evaluate the checkbox state correctly.
Number

Number / Currency

Amount > 50000
Use numeric comparison operators — greater than, less than, equals. Do not include currency symbols or thousand separators — compare against the raw number value (50000, not £50,000).
Text

Text / Long Text

Account.BillingCountry contains "Germany"
Use equals for exact matches, contains for partial matches in longer text fields. Contains is case-insensitive in most contexts — test both cases to confirm behaviour.
Date

Date / DateTime

CloseDate < TODAY
Use comparison operators with date values. TODAY is a dynamic keyword that resolves at generation time. Use ISO format for static dates: 2026-12-31. Avoid hardcoded dates in production templates.
Blank check

Empty / Null check

Custom_Terms__c is not blank
Use is blank to detect fields with no value, is not blank to detect fields that have any value. Works on all field types — useful for optional fields where absence means "use default".

Step-by-step: hiding a section using a Salesforce field

This example hides the "Standard Payment Terms" paragraph when the Custom_Terms__c field on the Opportunity is populated — ensuring custom terms replace the standard terms rather than both appearing.

1

Click the "Standard Payment Terms" paragraph in the editor

Open your template in the editor. Click the paragraph that contains the standard payment terms text. The paragraph is selected — you can see a blue outline around it.

2

Open the Conditional Logic tab in the element properties

In the right-hand properties panel, click Conditional Logic. Click Add Condition. The condition builder opens with three fields: Field, Operator, Value.

3

Set the condition: Custom_Terms__c is not blank

  • Field: Select Custom_Terms__c from the field picker
  • Operator: Select is not blank
  • Value: Leave empty — the "is not blank" operator needs no comparison value
4

Set the action to "Hide when condition is true"

In the Action dropdown below the condition, select Hide when condition is true. This means: when Custom_Terms__c has a value, hide the standard terms. When it's blank, show the standard terms.

5

Save and preview against two test records

Save the template. Preview it against a record with Custom_Terms__c populated — the standard paragraph should be absent. Preview again against a record with Custom_Terms__c blank — the standard paragraph should appear. Both outcomes verified.


Pattern library — ready-to-use show/hide conditions

Copy these patterns directly into your templates. All use Show when true unless noted.

Contract / Legal

Show GDPR data processing annex for EU customers

Field: Account.BillingCountry — Operator: contains — Value: country name (repeat with OR for each EU country, or use a formula field that categorises by region). Show when true.

Proposal

Show enterprise SLA only for large deals

Field: Amount — Operator: greater than or equal — Value: 100000. Show when true. If you also want a "Growth SLA" for medium deals, add an else-if: Amount >= 25000 shows Growth SLA, else shows Standard SLA.

Invoice

Show late payment fee clause only when applicable

Field: Late_Fee_Applicable__c (checkbox) — Operator: is true. Show when true. The late fee clause is completely invisible on invoices where it doesn't apply.

Proposal / Contract

Show renewal-specific introduction for returning customers

Field: Is_Renewal__c (checkbox) — Operator: is true. Show when true. Add an else branch showing the new-customer introduction when Is_Renewal__c is false. One template, two openers.

Quote / Proposal

Show custom pricing note only when custom pricing is in use

Field: Pricing_Override__c (text) — Operator: is not blank. Show when true. The note "This quote reflects negotiated pricing — standard rates may apply to future orders" appears only when there's a pricing override reason on record.

Any document

Hide a section for internal accounts (test/demo records)

Field: Account.Type — Operator: equals — Value: Internal. Hide when true. Prevents internal test records from generating documents with customer-facing clauses. An important safeguard for demo environments.


Handling whitespace after hidden sections

When a section is hidden, Dochly removes the element entirely — including any paragraph spacing above and below it. In most cases this produces clean results. However, if you have a section heading immediately above a conditional body paragraph, the heading may remain when the body is hidden.

Group heading and body together

The cleanest pattern: wrap both the section heading and the conditional body paragraph in a container or group element, then apply the show/hide condition to the entire group. Both heading and body disappear together — no orphaned headings.

Apply condition to the heading too

If grouping isn't available, apply the same condition to the heading element separately — using the same field, operator, and value. Both the heading and body will hide together. Keep both conditions identical so they always toggle in sync.

The recommended pattern is always to group conditional content — heading, body text, and any sub-elements — in a single container and apply the condition to the container. This is safer than applying conditions individually to multiple sibling elements, and prevents orphaned content if you later add more content to the section.


Testing show/hide conditions

Every show/hide condition has two outcomes — the element is shown or it isn't. Both must be tested before setting a template Active.

Test the "shown" state

Preview the template using a record where the condition is true — e.g. for Amount > 50,000, use a real Opportunity with a high amount. Confirm the section appears in the correct position, with correct content, and no formatting issues from the surrounding text.

Test the "hidden" state

Preview using a record where the condition is false — e.g. a low-value Opportunity. Confirm the section is completely absent. Check the surrounding paragraphs flow cleanly together with no extra blank lines or spacing where the section was.


Frequently asked questions

No. Hidden sections are completely removed from the document at generation time — no blank lines, no placeholder space, no empty pages. The content above and below the hidden section flows together naturally, as if the section was never in the template. If you are seeing blank space after a hidden section, it usually means there is a blank paragraph or extra line break outside the conditional element — check the template structure in the editor.
Yes. Multi-select picklist values are stored as semicolon-separated strings in Salesforce. Use the contains operator to check if a specific value is selected — e.g. Services_Included__c contains "Training". This returns true whether "Training" is the only value selected or one of several. Avoid using equals for multi-select picklists — equals only matches the exact full string including all selected values.
Yes. Add multiple conditions to the same element and set them to AND or OR logic. For example, to show an "Enterprise & EU" section only for large deals from EU countries: Condition 1 — Amount > 100000, Condition 2 — Account.BillingCountry contains "Germany" (or add more OR conditions for other EU countries). Set to AND so both must be true. The section only appears when both conditions pass simultaneously.
Check four things in order: (1) Confirm the field name is correct — an incorrect field name evaluates as blank, which can make conditions always true or always false; (2) Check the picklist value exactly matches the Salesforce picklist label — casing matters; (3) Confirm the field has the expected value on the test record — open the record in Salesforce and verify the field value directly; (4) Check whether you chose "Show when true" vs "Hide when true" correctly — a reversed action produces the opposite of what you expect. See Troubleshooting conditional logic for a full diagnostic guide.

Show/hide conditions are now working in your template. Next in this series: Use if/else conditions in a Dochly document template — switch inline text, output different clauses, and build multi-branch logic within a single paragraph or sentence.

Dochly
Salesforce AppExchange — UTECH HUB Install Dochly on AppExchange

Rated 5 stars · Native Salesforce app · Free to install