0

I am trying to create a conditional formula for a merge field for a HTML Email Template with the following logic; IF both ICMS ID and Portal ID are present then only show ICMS ID OR IF only ICMS ID is present show that IF only Portal ID is present show that

I created the following formula

 {!IF 
     (AND(NOT(ISBLANK(Case.ICMS_ID__c & Case.Portal_ID__c))), Case.ICMS_ID__c, ""
,
    
    !IF(NOT(ISBLANK(Case.ICMS_ID__c)), Case.ICMS_ID__c, ""
,
    
    !IF(NOT(ISBLANK(Case.Portal_ID__c)), Case.Portal_ID__c , ""
,
    
}

I am not sure where I am going wrong but the required information is not coming into the email template. If the field is filled out, no information is appearing.

I am not sure where I am going wrong, please help!

EDIT: Have tried the suggestion from below and still no information is appearing

  {!IF(AND(NOT(ISBLANK(Case.ICMS_ID__c)),
             NOT(ISBLANK(Case.Portal_ID__c))), 
                             Case.ICMS_ID__c, "",  
     !IF(NOT(ISBLANK(Case.ICMS_ID__c)),
                             Case.ICMS_ID__c, "",  
     !IF(NOT(ISBLANK(Case.Portal_ID__c)), 
                             Case.Portal_ID__c , "",  
}

EDIT: Have now also tried the below suggestion and the field on the email template is still appearing as blank even if data is entered in both ICMS ID & Portal ID or just one of them.

     {!IF(
        AND(NOT(ISBLANK(Case.ICMS_ID__c)), NOT(ISBLANK(Case.Portal_ID__c))), 
            Case.ICMS_ID__c,  
            IF(NOT(ISBLANK(Case.ICMS_ID__c)),
                Case.ICMS_ID__c,  
                IF(NOT(ISBLANK(Case.Portal_ID__c)), 
                    Case.Portal_ID__c, 
                    ""  
                )
            )
        )

}
2
  • what object is this HTML Email Template's Email Alert associated with?
    – cropredy
    Oct 25, 2022 at 22:32
  • there is no email alert, this is being used as a manual template for cases
    – asidrey
    Oct 26, 2022 at 19:58

3 Answers 3

2

Try using this formula -

 {!IF(
    AND(NOT(ISBLANK(Case.ICMS_ID__c)), NOT(ISBLANK(Case.Portal_ID__c))), 
        Case.ICMS_ID__c,  
        IF(NOT(ISBLANK(Case.ICMS_ID__c)),
            Case.ICMS_ID__c,  
            IF(NOT(ISBLANK(Case.Portal_ID__c)), 
                Case.Portal_ID__c, 
                ""  
            )
        )
    )
}

We don't have to use exclamation marks each and every time. If using multiple exclamation signs within single pair of curly braces, those were treated as NOT logical operators.

1
  • Hi Gaurav, thank you so much. Nothing is appearing still in the required field on the email and I am not sure what else to try.
    – asidrey
    Oct 25, 2022 at 21:38
1

ISBLANK() only accepts one field, so ISBLANK(Case.ICMS_ID__c & Case.Portal_ID__c) is invalid. You need a separate ISBLANK for each field.

1
  • Thanks for your comment, I tried your suggestion and still nothing is appearing in the email {!IF (AND (NOT (ISBLANK (Case.ICMS_ID__c)),NOT(ISBLANK(Case.Portal_ID__c))), Case.ICMS_ID__c, "", !IF(NOT(ISBLANK(Case.ICMS_ID__c)), Case.ICMS_ID__c, "", !IF(NOT(ISBLANK(Case.Portal_ID__c)), Case.Portal_ID__c , "", }
    – asidrey
    Oct 25, 2022 at 0:46
0

This is the final formula I came up with that satisfied all requirements. As always, the simplest answer ended up being the best.

{!IF
    (ISBLANK(Case.Portal_ID__c), IF(ISBLANK(Case.ICMS_ID__c), "", 
        (Case.ICMS_ID__c)), (Case.Portal_ID__c))}
1
  • 1
    alternative practice is to use NULL instead of ""; avoids potential formula syntax errors
    – cropredy
    Nov 8, 2022 at 5:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .