# Conditional Logic Working Examples

## Basic Structure:

**Scenario:** Render only if Opportunity stagename is ‘Closed Won’:

```
<!--RENDER='{{!Opportunity.stagename}}' == 'Closed Won' -->
  This is opportunity is currently in the Prospecting phase. 
<!--ENDRENDER-->
```

***

**Scenario:** Render ‘No phone number on record. Please update.’ if contact phone number is missing. Otherwise, display the phone number.

```
<!--RENDER='{{!Contact.Phone}}' == 'NULL' -->
  No phone number on record. Please update.
<!--ENDRENDER-->
<!--RENDER='{{!Contact.Phone}}' != 'NULL' -->
  Phone number: {{!Contact.Phone}}
<!--ENDRENDER-->
```

***

**Scenario:** Render ‘This contact is marked active.’ if Contact record is active.

```
<!--RENDER='{{!Contact.IsActive__c}}' == 'True' -->
  This contact is marked active.
<!--ENDRENDER-->
```

## AND / OR Structure:

**Scenario:** Render only if Opportunity stagename is ‘Closed Won’:

```
<!--RENDER='{{!Opportunity.stagename}}' == 'Prospecting' -->
  This is opportunity is currently in the Prospecting phase. 
<!--ENDRENDER-->
```

***

**Scenario:** Render ‘No phone number on record. Please update.’ if contact phone number is missing. Otherwise, display the phone number.

```
<!--RENDER='{{!Contact.Phone}}' == 'NULL' -->
  No phone number on record. Please update.
<!--ENDRENDER-->
<!--RENDER='{{!Contact.Phone}}' != 'NULL' -->
  Phone number: {{!Contact.Phone}}
<!--ENDRENDER-->
```

***

**Scenario:** Render ‘This contact is marked active.’ if Contact record is active.

```
<!--RENDER='{{!Contact.IsActive__c}}' == 'True' -->
  This contact is marked active.
<!--ENDRENDER-->
```

***

**Scenario:** Add special terms for customers in restricted regions with active agreements.

```
<!--RENDER=( ('{{!Account.BillingState}}' == 'CA' || '{{!Account.BillingState}}' == 'NV') 
            && '{{!Account.Active_Contract__c}}' == 'True' ) -->
  Customer is in a West Coast region (CA/NV) and currently has an active contract.
<!--ENDRENDER-->

```

***

**Scenario:** Escalation or special reporting for high-impact cases.

```
<!--RENDER=( '{{!Case.Priority}}' == 'High' 
            && ( '{{!Case.Root_Cause__c}}' != 'NULL' || '{{!Case.Category__c}}' == 'Security' ) ) -->
  This high-priority case either has a documented root cause or is categorized as Security.
<!--ENDRENDER-->

```

***

**Scenario:** Add fulfillment or onboarding sections only when both monetary and readiness conditions are met.

```
<!--RENDER=( ( {{!Opportunity.Amount}} > 20000 || '{{!Opportunity.StageName}}' == 'Closed Won' )
            && '{{!Opportunity.Delivery_Date__c}}' != 'NULL' ) -->
  This opportunity meets major criteria (Closed Won or >$20k) and has a confirmed delivery date.
<!--ENDRENDER-->

```

***

### **Scenario:** Show a message if the customer is in CA or NV **and** either has an active contract or a pending renewal.

```
<!--RENDER=( ('{{!Account.BillingState}}' == 'CA' || '{{!Account.BillingState}}' == 'NV') 
            && ('{{!Account.Active_Contract__c}}' == 'True' || '{{!Account.Pending_Renewal__c}}' == 'True') ) -->
  Customer is in CA or NV and has an active contract or a pending renewal.
<!--ENDRENDER-->
```

***

**Scenario:** Display partner-specific compliance, data handling, or NDA sections.

```
<!--RENDER=( '{{!Account.Partner__c}}' == 'True' 
            && ( '{{!Account.Industry}}' == 'Finance' || '{{!Account.Industry}}' == 'Legal' ) ) -->
  This partner operates in the Finance or Legal industry.
<!--ENDRENDER-->
```

## Nested Structure:

**Scenario:** Specialized clauses for California Healthcare companies.

```
<!--RENDER='{{!Account.BillingState}}' == 'CA' -->
  This customer is located in California.
  <!--RENDER1='{{!Account.Industry}}' == 'Healthcare' -->
    They operate in the Healthcare industry.
  <!--ENDRENDER1-->
<!--ENDRENDER-->
```

***

**Scenario:** Post-sale documentation where deeper sections only apply when prerequisites exist.

```
<!--RENDER='{{!Opportunity.StageName}}' == 'Closed Won' -->
  Congratulations on your purchase!
  <!--RENDER1='{{!Opportunity.Install_Date__c}}' != 'NULL' -->
    Installation is scheduled for {{!Opportunity.Install_Date__c}}.
    <!--RENDER2='{{!Opportunity.Warranty_Level__c}}' == 'Premium' -->
      You qualify for our **Premium Warranty** coverage.
    <!--ENDRENDER2-->
  <!--ENDRENDER1-->
<!--ENDRENDER-->
```

***

**Scenario:** Multi-level logic based on contract type, term length, and settings.

```
<!--RENDER='{{!Contract.Type}}' == 'Renewal' -->
  This is a renewal contract.
  <!--RENDER1='{{!Contract.Term_Months__c}}' > '12' -->
    This is considered a long-term renewal.
    <!--RENDER2='{{!Contract.Auto_Renew__c}}' == 'True' -->
      The contract will renew automatically unless written notice is provided.
    <!--ENDRENDER2-->
  <!--ENDRENDER1-->
<!--ENDRENDER-->
```

***

**Scenario:** Progressive detail based on available phone data.

```
<!--RENDER='{{!Contact.Phone}}' != 'NULL' -->
  Primary Phone: {{!Contact.Phone}}
  <!--RENDER1='{{!Contact.MobilePhone}}' != 'NULL' -->
    Mobile Phone: {{!Contact.MobilePhone}}
    <!--RENDER2='{{!Contact.Mobile_Verified__c}}' == 'True' -->
      Mobile number has been verified.
    <!--ENDRENDER2-->
  <!--ENDRENDER1-->
<!--ENDRENDER-->
```

***

**Scenario:** Complex account summaries in executive-level reports.

```
<!--RENDER='{{!Account.Customer_Type__c}}' == 'High Value' -->
  This is a high-value customer.
  <!--RENDER1='{{!Account.Region__c}}' == 'North America' -->
    Customer is located in North America.
    <!--RENDER2='{{!Account.Strategic_Account__c}}' == 'True' -->
      This account is marked as **Strategic**.
    <!--ENDRENDER2-->
  <!--ENDRENDER1-->
<!--ENDRENDER-->
```

***

**Scenario:** Escalation or RCA documentation.

```
<!--RENDER='{{!Case.Priority}}' == 'High' -->
  This case is high priority.
  <!--RENDER1='{{!Case.Root_Cause__c}}' != 'NULL' -->
    Root Cause: {{!Case.Root_Cause__c}}
    <!--RENDER2='{{!Case.Customer_Visible__c}}' == 'True' -->
      This information is visible to the customer.
    <!--ENDRENDER2-->
  <!--ENDRENDER1-->
<!--ENDRENDER-->
```

***

**Scenario:** Automated pricing or approval sheets.

```
<!--RENDER='{{!Opportunity.Type}}' == 'Renewal' -->
  Renewal opportunity.
  <!--RENDER1='{{!Opportunity.Discount__c}}' > '0' -->
    This renewal includes a discount.
    <!--RENDER2='{{!Opportunity.Manager_Approval__c}}' == 'Approved' -->
      Discount has been approved by the manager.
    <!--ENDRENDER2-->
  <!--ENDRENDER1-->
<!--ENDRENDER-->
```

***

**Scenario:** Line-item logic inside S-Docs loops.

```
<!--RENDER='{{!SDOC.loop_OpportunityLineItem}}' != 'NULL' -->
  The quote includes products.
  <!--RENDER1='{{!OpportunityLineItem.Family}}' == 'Software' -->
    Software product identified.
    <!--RENDER2='{{!OpportunityLineItem.Quantity}}' > '10' -->
      Order qualifies for volume pricing.
    <!--ENDRENDER2-->
  <!--ENDRENDER1-->
<!--ENDRENDER-->
```

***

**Scenario:** Shipping detail blocks or packing slips.

```
<!--RENDER='{{!Order.ShippingState}}' == 'NY' -->
  Shipping to New York.
  <!--RENDER1='{{!Order.Delivery_Method__c}}' == 'Ground' -->
    This order is set to Ground Shipping.
    <!--RENDER2='{{!Order.Expedited__c}}' == 'True' -->
      Expedited ground delivery requested.
    <!--ENDRENDER2-->
  <!--ENDRENDER1-->
<!--ENDRENDER-->

```

***

**Scenario:** Billing, compliance, or financial management templates. (4 Levels Deep)

```
<!--RENDER='{{!Account.Active__c}}' == 'True' -->
  Account is active.
  <!--RENDER1='{{!Account.Risk_Level__c}}' == 'High' -->
    Risk level is high.
    <!--RENDER2='{{!Account.Overdue_Balance__c}}' > '0' -->
      Customer has an overdue balance.
      <!--RENDER3='{{!Account.Collections_Status__c}}' == 'In Collections' -->
        Customer is currently in collections. Immediate action required.
      <!--ENDRENDER3-->
    <!--ENDRENDER2-->
  <!--ENDRENDER1-->
<!--ENDRENDER-->
```

## CONTAINS Structure:

**Scenario:** Include a greeting paragraph if the contact’s name contains “Tim”.

```
<!--RENDER='{{!Contact.Name}}' CONTAINS 'Tim' -->
  Hello Tim! We’re excited to connect with you.
<!--ENDRENDER-->

```

***

**Scenario:** Highlight special handling instructions if the opportunity description does not contain the word “Urgent”.

```
<!--RENDER='{{!Opportunity.Description}}' Not CONTAINS 'Urgent' -->
  This opportunity requires immediate attention.
<!--ENDRENDER-->

```

***

**Scenario:** Show a refund clause if any case comment mentions “Refund”.

```
<!--RENDER='{{!Case.Comments}}' CONTAINS 'Refund' -->
  Please follow the refund procedure outlined in the company policy.
<!--ENDRENDER-->

```

***

**Scenario:** Include financial compliance instructions for accounts in industries containing the word “Finance”.

```
<!--RENDER='{{!Account.Industry}}' CONTAINS 'Finance' -->
  Please ensure all regulatory compliance forms are completed.
<!--ENDRENDER-->

```

***

**Scenario:** Add a note if a product in the quote contains “Professional” in its name.

```
<!--RENDER='{{!OpportunityLineItem.Product2.Name}}' CONTAINS 'Professional' -->
  This is a Pro version product and includes additional premium support.
<!--ENDRENDER-->
```

## Complex Solution:

### **Scenario:**

You want to generate a customer communication that includes:

{% stepper %}
{% step %}
Only for **active accounts**.
{% endstep %}

{% step %}
If the account is in **California or New York** **AND** either has a **“Premium” contract** or the account **name contains “Enterprise”**.
{% endstep %}

{% step %}
Include a **special note** if the **opportunity description contains “Urgent”**.
{% endstep %}

{% step %}
Nested logic: inside that, include a **custom greeting** if the contact’s **title contains “Manager”**.
{% endstep %}
{% endstepper %}

***

### **Complex Nested RENDER Example**

```
<!--RENDER=( '{{!Account.Active__c}}' == 'True' ) -->
  This message is for an active account.

  <!--RENDER=( ('{{!Account.BillingState}}' == 'CA' || '{{!Account.BillingState}}' == 'NY') 
               && ('{{!Account.Contract_Type__c}}' == 'Premium' || '{{!Account.Name}}' CONTAINS 'Enterprise') ) -->
    Special terms apply for your account based on location and contract status.

    <!--RENDER='{{!Opportunity.Description}}' CONTAINS 'Urgent' -->
      Note: This opportunity is marked as urgent. Immediate action is recommended.
    <!--ENDRENDER-->

    <!--RENDER1='{{!Contact.Title}}' CONTAINS 'Manager' -->
      Dear Manager, we have tailored recommendations for your review.
    <!--ENDRENDER1-->

  <!--ENDRENDER-->

<!--ENDRENDER-->
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.sdocs.com/developer-hub/template-configuration-and-styling/conditional-logic-reference/conditional-logic-working-examples.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
