How to Show or Hide Content Automatically
Show or hide template sections with field checks, blank-value rules, and multi-part conditions.
Use this tutorial when one template must generate different output for different records.
What it looks like
After setup, one quote can produce all of this:
A VIP message only for high-value customers
A phone line only when
Contact.Phonehas a valueA California clause only for active contracts
A finance compliance note only for matching industries
Reusable rule patterns for other templates
This works well for quotes, contracts, and renewal documents.
When to use conditional logic
Use conditional logic when content should appear only when record data passes a rule.
Best for:
Hiding empty labels and optional sections
Showing regional or industry-specific clauses
Reusing one template across several customer scenarios
Use another feature when the job is different:
Use Template Attributes Tutorial when you need formatting only.
Use Get Started with Calculations when you need thresholds or derived values.
Use Creating Your First Named Query when you need reusable query output.
Build a quote template with conditional logic
What you'll configure
A basic
RENDERblockEmpty-field checks with
!= 'NULL'Multi-part rules with
&&and||Keyword matching with
CONTAINSA quick test plan for validating output
Estimated time: 20 minutes
Prerequisites
Before you start, make sure you have:
Access to S-Docs Templates
Permission to create or edit templates
An S-Docs template related to
Account,Contact, orOpportunityTest records with known field values
Basic familiarity with merge fields such as
{{!Account.Name}}
If you are brand new to S-Docs syntax, start with a merge field tutorial first.
Step 1: Open or create the template
Start with a template that should change by record data.
Go to S-Docs Templates in Salesforce.
Open an existing template or click New Template.
Set the correct base object.
Open the template editor.
Click Source if you want to paste syntax directly.
You now have a place to add conditional blocks.
Step 2: Add a simple equality check
Start with one short block. This confirms the syntax works before you add more logic.
Add this where the VIP note should appear:
What you just did:
Compared
Account.Customer_Type__cto one exact text valueUsed
==for an equality checkRendered the paragraph only when the condition passes
How to read the syntax:
{{!Account.Customer_Type__c}}is the field being checked==means the value must match exactly'High Value'is the required text
Step 3: Hide a blank phone line
Use a null check when the label and value should appear together.
Add this block in the contact section:
What you just did:
Used
!=for a not-equal checkCompared the field to
NULLPrevented an empty
Phone:label from printing
This pattern works well for phone, email, title, and address lines.
Step 4: Require two conditions with AND
Use AND logic when both checks must pass before showing content.
Add this clause below the customer summary:
What you just did:
Used
&&for AND logicGrouped both checks with parentheses
Rendered the clause only when both values match
Read the condition in order:
BillingStatemust equalCAActive_Contract__cmust equalTrue&&means both statements must be true
Step 5: Match either value with OR
Use OR logic when one of several values should show the same content.
Add this example:
What you just did:
Used
||for OR logicAllowed either state to trigger the note
Reused the same field in two checks
Use this pattern for state groups, segment groups, or status groups.
Step 6: Match a keyword with CONTAINS
Use CONTAINS when the source text can vary.
Add this block in the compliance section:
What you just did:
Searched within the full field value
Matched text like
Finance TeamorGlobal FinanceAvoided relying on one exact field value
If you need the inverse, use NOT CONTAINS.
Step 7: Save and test the output
Test one rule at a time before combining more patterns.
Click Save in the template editor.
Generate the template from a record that should pass one rule.
Generate it again from a record that should fail.
Compare the output blocks.
Verify these results:
The VIP note shows only for high-value customers
The phone line shows only when
Contact.Phoneis populatedThe California clause shows only when both checks pass
The finance note shows only when the keyword exists
Try these variations
Use these once the base version works.
An amount threshold:
A negative keyword match:
A combined customer and industry check:
Guardrails and limits
Syntax rules
Always close each block with
<!--ENDRENDER-->.Always keep the full label and value inside the same block.
Always use exact field API names.
If you miss the closing tag, later content can disappear.
Operator rules
Use
==for exact matches.Use
!= 'NULL'for blank-value checks.Wrap multi-part conditions in parentheses.
If the operator is wrong, the block stays hidden.
Text-matching rules
Match text values exactly when you use
==.Use
CONTAINSwhen field values vary.Check capitalization and spacing in test data.
If the value differs, S-Docs skips the block.
Testing rules
Generate one document after each major syntax change.
Test one condition alone before combining conditions.
Use records that clearly pass and fail each rule.
If you skip this, debugging gets much slower.
Last updated
Was this helpful?

