Use IF Else condition within Process Email Template

Hi,

I tried to use below if else one-by-one in process email template html code but email comes with code and conditions are not working.

1. {if $check_service_c=="Yes"} sometext {/if}

2. <!--{if $check_service_c=="Yes"} sometext {/if}-->

3. <!--{{#if {::Leads::check_service_c::} == "Yes" }} sometext {{else}} sometext 2{{/if}}-->

4. {{#if {::Leads::check_service_c::} == "Yes" }} sometext {{else}} sometext 2{{/if}}

My requirement is, If checkbox is checked than show sometext

Any help will be highly appreciable

Regards

  • I assume $check_service_c is a checkbox. I believe checkboxes evaluate to true/false.

    {if $check_service_c} optionA {else} optionB {/if}

    this syntax works in PDF manager, which also uses smarty:

    {if $fields.check_service_c} optionA {else} optionB {/if}

    I hope this helps,

    FrancescaS

  • Hi Muhammad,

    If Francesca's suggestion doesn't work, I found the Smarty Documentation page for if/else statements. In the comments it was noted that spaces are required before and after the "==". I also noticed that all of the examples use single quotes for string comparisons, though I'm not certain whether that matters. You might try:

    {if $check_service_c == 'Yes'}sometext{/if}

    I hope that helps!

    -Alan

  • Any suggestions  I want to use if statement in my template. Please help me. When i try to use  at above code, doesn't work.

  • The following all work for me in my Quotes template, hopefully you find some clues that help you. One thing I noticed is I use "eq" instead of "="

    {if !empty($fields.shipping_contact_name)}{$fields.shipping_contact_name}{/if}
    {if !empty($fields.shipping_email_address_c) and ($fields.business_region_c eq 'ABC')
    {$fields.shipping_email_address_c}
    {/if}
    {if isset($fields.billing_accounts.vat_c) and !empty($fields.billing_accounts.vat_c)}
    VAT No: {$fields.billing_accounts.vat_c}
    {/if}
    {if $product.discount_percent > 0}
    {$product.discount_percent}
    {else}
    {$product.discount_amount}
    {/if}

    FrancescaS

  • Has anybody found an answer to this?

    IF statements seem to work in Smarty / PDF Manager, but not in Process Email Template. 

    Also, the HTML editor keeps reformatting my code, for instance moving my if statement embedded in a table (eg; to display a row or not depending on a field value)

    Damien Pochon

    CRM & Digital consultant @ ITS4U Group

  • Hello, I know this post is very old... rather than make a new one I thought I would add a comment here.

    I have the same question:  is there a way to use ifelse inside a process definition email template?

    Note - Not PDF manager.  ifelse works great in there and is sooo handy!   If the same would be possible inside the email templates it could eliminate the need for multiple similar email templates...

    I feel like it is not supported though, nothing in here:

    https://support.sugarcrm.com/Documentation/Sugar_Versions/11.0/Sell/Administration_Guide/SugarBPM/Process_Email_Templates/#Designing_Process_Email_Templates

    Does anybody know if it can be done, in a different way to PDF's maybe?

    Thanks... anyone... :-)
    Luke.

  • Hi,

    I tried below in my process email template but not working :

    "{if !empty($fields.choose_module_c) and ($fields.choose_module_c eq 'Company')} {::accounts::name::} {/if} {if !empty($fields.choose_module_c) and ($fields.choose_module_c eq 'Investor')} {::avds_Investors::name::} {/if}"

    Please help me.

    output is coming as in email received as below:

    "

    {if !empty($fields.choose_module_c) and ($fields.choose_module_c eq 'Company')}
    kcb
    {/if}

    {if !empty($fields.choose_module_c) and ($fields.choose_module_c eq 'avds_Investors')}
    kcb-PE-2023
    {/if}"

    THanks,

    Shreya