DRTE v5.137 (GA)
DRTE v5.137
What’s New
- Template Engine:Dynamic HTML Conditional Rendering
- New Source HTML Action Buttons - Minify and Indent
A. TemplateEngine: Dynamic HTML Conditional Rendering
Purpose
Process HTML templates with Salesforce SOQL data and render conditional blocks dynamically.
Overview
TemplateEngine is a lightweight conditional rendering engine that processes HTML strings containing special template tags. It evaluates if/else conditions against Salesforce SOQL record data and returns the appropriate HTML block - without modifying any content outside the conditional blocks.
How It Works
The engine follows a simple three-step pipeline:
SOQL Response | HTML Template String | Rendered HTML Output | ||
JSON from SOQL query | → | Contains {{#if}}, {{else}}, {{/if}} tags and field placeholders | → | Conditional blocks resolved, |
1. TEMPLATE SYNTAX
a. Basic If Block
Use when you want to show content only when a condition is true, and nothing otherwise.
{{#if FieldName}}
Content to show when condition is true
{{/if}}
b. If / Else Block
Use when you want different content depending on whether the condition is true or false.
{{#if FieldName == 'Value'}}
Content when condition is TRUE
{{else}}
Content when condition is FALSE
{{/if}}
c. Template From Salesforce Rich Text Editor
When the HTML string comes from the Salesforce Rich Text Editor (RTE), special characters are automatically HTML-encoded. The engine handles this transparently and no manual decoding needed.
<!-- RTE encodes single quotes as ' -->
{{#if Account.BillingStreet == 'Rajasthan'}}
Rajasthan Office
{{else}}
{{Account.BillingStreet}}
{{/if}}
d. Multiple Blocks in One Template
A single HTML string can contain multiple independent conditional blocks. Each is processed separately.
{{#if IsPaid__c}}
<span class='badge green'>PAID</span>
{{else}}
<span class='badge red'>UNPAID</span>
{{/if}}
{{#if StageName == 'Prospecting'}}
<p>Early stage opportunity</p>
{{/if}}
{{#if Amount > 50000}}
<div class='highlight'>High Value Deal</div>
{{else}}
<div>Standard Deal</div>
{{/if}}
2. CONDITION EXPRESSIONS
Conditions are written inside {{#if ... }} and support a wide range of comparisons and field types.
3. SUPPORTED OPERATORS
Operator | Meaning | Example |
== or === | Equal to | StageName == 'Prospecting' |
!= or !== | Not equal to | Status__c != 'Closed' |
> | Greater than | Amount > 10000 |
>= | Greater than or equal | Amount >= 50000 |
< | Less than | Amount < 1000 |
<= | Less than or equal | Discount__c <= 20 |
&& | AND — both must be true | IsPaid__c && Amount > 1000 |
|| | OR — at least one true | StageName == 'Closed' || Amount > 99999 |
4. FIELD TYPES
Field Type | Example Condition | Notes |
String / Text | StageName == 'Active' | Wrap string values in single quotes |
Number / Currency | Amount > 50000 | No quotes — compared as numeric |
Boolean (Checkbox) | IsPaid__c | Field alone — true if checked, false if not |
Boolean explicit | IsPaid__c == true | Explicit comparison also works |
Null / Empty field | Website | Returns false if field has no value |
Relational field | Account.BillingStreet == 'Rajasthan' | Use dot notation for relationship fields |
|
5. COMPOUND CONDITIONS
Combine multiple conditions using && (AND) or || (OR).
<!-- AND — both conditions must be true -->
{{#if StageName == 'Prospecting' && Amount > 10000}}
High-value early stage deal
{{/if}}
<!-- OR — at least one condition must be true -->
{{#if StageName == 'Closed Won' || IsPaid__c}}
Revenue confirmed
{{else}}
Pending
{{/if}}
6. FIELD REFERENCES
6.1 Standard Salesforce Fields
Use the Salesforce API field name exactly as returned by the SOQL query.
<!-- Direct fields on the queried object -->
{{#if Name}}...{{/if}}
{{#if StageName == 'Closed Won'}}...{{/if}}
{{#if Amount > 5000}}...{{/if}}
{{#if IsPaid__c}}...{{/if}} <!-- custom checkbox field -->
{{#if Status__c == 'Active'}}...{{/if}} <!-- custom picklist field →
6.2 Relationship / Referential Fields
Access fields from related objects using dot notation. This matches the SOQL query structure.
<!-- SOQL: SELECT Id, Name, Account.BillingStreet FROM Opportunity -->
{{#if Account.BillingStreet == 'Rajasthan'}}
Rajasthan Office
{{else}}
{{Account.BillingStreet}}
{{/if}}
Example :
{{#if Owner.Name == 'John Doe'}}
Owned by John
{{/if}}
6.3 Null / Empty Fields
If a field has no value in Salesforce, it evaluates as false in a condition. The else block (if present) will be rendered.
<!-- Account.Website has no value -->
{{#if Account.Website}}
<a href='{{Account.Website}}'>Visit Website</a>
{{else}}
No website on file
{{/if}}
<!-- Result: 'No website on file' →
7. ENGINE BEHAVIOUR REFERENCES
7.1 What process “If” Returns
Scenario | Returns | Notes |
Condition is true, truthy block exists | Truthy block content (raw) | |
Condition is false, else block exists | Else block content (raw) | |
Condition is false, no else block | Empty string "" | Block removed entirely |
Field is null/missing | Evaluates as false | Goes to else block or returns empty |
Field exists with any value | Evaluates as true | For non-boolean truthy check |
7.2 What Is NOT Processed
OUT OF SCOPE | nested {{#if}} inside another {{#if}} |
8. Full Examples
8.1 Invoice Status Document
<!-- SOQL: SELECT Id, Name, IsPaid__c, Amount, Account.BillingStreet FROM Opportunity -->
<div class='document'>
{{#if IsPaid__c}}
<span class='badge green'>PAID</span>
{{else}}
<span class='badge red'>UNPAID</span>
{{/if}}
{{#if Amount > 50000}}
<div class='highlight'>High Value Account</div>
{{/if}}
{{#if Account.BillingStreet == 'Rajasthan'}}
<p>Rajasthan Regional Office</p>
{{else}}
<p>{{Account.BillingStreet}}</p>
{{/if}}
</div>
8.2 Opportunity Stage Section
<!-- SOQL: SELECT Id, Name, StageName, Amount FROM Opportunity -->
{{#if StageName == 'Closed Won'}}
<div class='success'>
<h2>Deal Closed</h2>
<p>Congratulations on closing {{Name}}!</p>
</div>
{{else}}
{{#if StageName == 'Prospecting' && Amount > 10000}}
<div class='priority'>Priority Prospect — Follow Up Required</div>
{{else}}
<div class='standard'>{{Name}} — Stage: {{StageName}}</div>
{{/if}}
{{/if}}
8.3 Iterate HTML for Multiple Records
When the section is set to iterate HTML for records, the same template is processed once per SOQL result row.
<!-- Template applied to each record in SOQL results -->
<div class='record-row'>
{{#if StageName == 'Qualification'}}
<strong>{{Name}}</strong>
{{else}}
No Name
{{/if}}
</div>
<!-- Output for record 1 (StageName = Prospecting): -->
<div class='record-row'>No Name</div>
<!-- Output for record 2 (StageName = Qualification): -->
<div class='record-row'><strong>{{Name}}</strong></div>
9. Common Mistakes & How to Avoid Them
Mistake | Wrong | Correct |
Field not in SOQL query | {{#if Website}} but Website not in SELECT | Add Website to SOQL: SELECT Id, Name, Website FROM Account |
Missing quotes around string value | {{#if StageName == Prospecting}} | {{#if StageName == 'Prospecting'}} |
Wrong API field name casing | {{#if stagename == 'Prospecting'}} | {{#if StageName == 'Prospecting'}} |
Relational field not queried | {{#if Account.BillingStreet == 'X'}} but no Account.BillingStreet in SELECT | SELECT Id, Account.BillingStreet FROM Opportunity |
10. Quick Reference Card
Template Syntax {{#if Field}}...{{/if}} {{#if Field}}...{{else}}...{{/if}} {{#if Field == 'Value'}}...{{/if}} {{#if Amount > 1000}}...{{/if}} {{#if IsPaid__c}}...{{/if}} {{#if A == 'x' && B > 10}}...{{/if}} {{#if A == 'x' || B == 'y'}}...{{/if}} | Key Rules Field names are case-sensitive (use API name) String values must be in single quotes Numeric values need no quotes Boolean fields: use field name alone Null fields evaluate to false RTE encoded chars decoded automatically {{Field}} outside if blocks returned as-is {{Field}} inside matched block returned as-is |
B. Source HTML Action Buttons - Minify and Indent in HTML Content Builder