function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rung41Rung41 

Not sure how to write this case statement

Basically..

If Opporuntiy showroom is Lake Forest use the email template with the id of 123456

If Opporuntiy showroom is Hosuton use the email template with the id of 987456

If Opporuntiy Showroom is Lake Forest but created by profile Id 8520 then use email template id 4560

If Opporuntiy Showroom is Houston but created by profile Id 8520 then use email template id 4560

 

Here is what my Case statement look like now

 

template_id={!CASE( Opportunity.Showroom__c  ,
'Lake Forest','00X30000001AGI9',
 'Houston','00X30000001AGWW',
'00X300000017004')}

Best Answer chosen by Admin (Salesforce Developers) 
zachelrathzachelrath

Two ways to write it.

 

(1) If you ALWAYS want to show Email Template 4560 if the Opportunity was Created By Profile 8520, regardless of the Opportunity's Showroom, then do this:

 

template_id={!

IF(Opportunity.CreatedBy.ProfileId = '8520','4560',
CASE(Opportunity.Showroom__c,
'Lake Forest','00X30000001AGI9',
'Houston','00X30000001AGWW',
'00X300000017004'
)
)
}

 

 

(2) But if Email Template is dependent on both Profile AND Showroom, then you'd probably want a modification to your original structure with inline IF clauses, like this:

 

template_id={!

CASE(Opportunity.Showroom__c,
'Lake Forest',
IF(Opportunity.CreatedBy.ProfileId = '8520','4560','00X30000001AGI9'),
'Houston',
IF(Opportunity.CreatedBy.ProfileId = '8520','7890','00X30000001AGWW'),
'00X300000017004'
)

}

 

All Answers

zachelrathzachelrath

Two ways to write it.

 

(1) If you ALWAYS want to show Email Template 4560 if the Opportunity was Created By Profile 8520, regardless of the Opportunity's Showroom, then do this:

 

template_id={!

IF(Opportunity.CreatedBy.ProfileId = '8520','4560',
CASE(Opportunity.Showroom__c,
'Lake Forest','00X30000001AGI9',
'Houston','00X30000001AGWW',
'00X300000017004'
)
)
}

 

 

(2) But if Email Template is dependent on both Profile AND Showroom, then you'd probably want a modification to your original structure with inline IF clauses, like this:

 

template_id={!

CASE(Opportunity.Showroom__c,
'Lake Forest',
IF(Opportunity.CreatedBy.ProfileId = '8520','4560','00X30000001AGI9'),
'Houston',
IF(Opportunity.CreatedBy.ProfileId = '8520','7890','00X30000001AGWW'),
'00X300000017004'
)

}

 

This was selected as the best answer
Rung41Rung41

Thanks! It works like a charm.