You need to sign in to do that
Don't have an account?
Joe Hayes
If statement to set variable
I am looking to set a variable depending on the value of a field.
EmailTemplate template =
if(a__c == 'a' || a__c == 'b'){
[SELECT Id, Subject, HtmlValue, Body FROM EmailTemplate WHERE Name = 'ab_Email']}
else {
[SELECT Id, Subject, HtmlValue, Body FROM EmailTemplate WHERE Name = 'c_Email']};
Please can someone show me the correct way to do this?
Thank you
Joe
EmailTemplate template =
if(a__c == 'a' || a__c == 'b'){
[SELECT Id, Subject, HtmlValue, Body FROM EmailTemplate WHERE Name = 'ab_Email']}
else {
[SELECT Id, Subject, HtmlValue, Body FROM EmailTemplate WHERE Name = 'c_Email']};
Please can someone show me the correct way to do this?
Thank you
Joe
Are you looking for something like this? Add your conditions for selecting the template.
Hope this helps.
All Answers
One of the ways to do it is :
But you have to be careful here because one of the queries can return "List has no rows to assign..." exception in case there are no records returned by SOQL.
Are you looking for something like this? Add your conditions for selecting the template.
Hope this helps.