You need to sign in to do that
Don't have an account?
Samantha Chua
Boolean if Statement stops codes from executing
Hi,
I have a snippet of conditional statements which are not executing ): Anyone knows what I am doing wrong?
These codes work:
However, when i add in one more condition to check, it stopped working ):
Here is a snippet:
What am I doing wrong in the boolean check?
Regards,
Samantha
I have a snippet of conditional statements which are not executing ): Anyone knows what I am doing wrong?
These codes work:
//Retrieving email from email template name EmailTemplate ABC = [SELECT ID FROM EmailTemplate WHERE DeveloperName = 'ABC']; EmailTemplate domainX = [SELECT ID FROM EmailTemplate WHERE DeveloperName = 'BCS']; EmailTemplate efg = [SELECT ID FROM EmailTemplate WHERE DeveloperName = 'EFG']; EmailTemplate evpl = [SELECT ID FROM EmailTemplate WHERE DeveloperName = 'HIJ']; if (c.Product__c.contains('ABC')) { templateId = ABC.Id; } else if (c.Product__c.equals('fib') || c.Product__c.equals('efg')){ templateId = efg.Id; } else if (c.Product__c.contains('Hosted') || c.Product__c.contains('Domain Name')){ templateId = domainX.Id; } else if (c.Product__c.contains('EVPL')){ templateId = evpl.Id; } }
However, when i add in one more condition to check, it stopped working ):
Here is a snippet:
//Retrieving email from email template name EmailTemplate ABC = [SELECT ID FROM EmailTemplate WHERE DeveloperName = 'ABC']; EmailTemplate domainX = [SELECT ID FROM EmailTemplate WHERE DeveloperName = 'BCS']; EmailTemplate efg = [SELECT ID FROM EmailTemplate WHERE DeveloperName = 'EFG']; EmailTemplate evpl = [SELECT ID FROM EmailTemplate WHERE DeveloperName = 'HIJ']; EmailTemplate DDosWS = [SELECT ID FROM EmailTemplate WHERE DeveloperName = 'abc']; EmailTemplate fiberWS = [SELECT ID FROM EmailTemplate WHERE DeveloperName = 'csd']; EmailTemplate evplWS = [SELECT ID FROM EmailTemplate WHERE DeveloperName = 'sds']; if (c.Sales_Type__c.equals('Wholesale')) { isWholesale = true; } else { isWholesale = false; } if (isWholesale == false) { if (c.Product__c.contains('abc')) { templateId = abc.Id; } else if (c.Product__c.equals('Fibernet') || c.Product__c.equals('Lite')){ templateId = efg.Id; } else if (c.Product__c.contains('Hosted') || c.Product__c.contains('Domain')){ templateId = domainX.Id; } else if (c.Product__c.contains('EVPL')){ templateId = evpl.Id; } } else { if (c.Product__c.contains('abc')) { templateId = DDosWS.Id; } else if (c.Product__c.equals('Fibernet') || c.Product__c.equals('Lite')){ templateId = fiberWS.Id; } else if (c.Product__c.contains('EVPL')){ templateId = evplWS.Id; } }
What am I doing wrong in the boolean check?
Regards,
Samantha
All Answers
//Retrieving email from email template name
EmailTemplate ABC = [SELECT ID FROM EmailTemplate WHERE DeveloperName = 'ABC'];
EmailTemplate domainX = [SELECT ID FROM EmailTemplate WHERE DeveloperName = 'BCS'];
EmailTemplate efg = [SELECT ID FROM EmailTemplate WHERE DeveloperName = 'EFG'];
EmailTemplate evpl = [SELECT ID FROM EmailTemplate WHERE DeveloperName = 'HIJ'];
EmailTemplate DDosWS = [SELECT ID FROM EmailTemplate WHERE DeveloperName = 'abc'];
EmailTemplate fiberWS = [SELECT ID FROM EmailTemplate WHERE DeveloperName = 'csd'];
EmailTemplate evplWS = [SELECT ID FROM EmailTemplate WHERE DeveloperName = 'sds'];
if (c.Sales_Type__c.equals('Wholesale')) {
isWholesale = true;
} else {
isWholesale = false;
}
if (isWholesale == false)
{
System.debug('-----inside-isWholesale-false------------->'+c.Product__c);
if (c.Product__c.contains('abc')) {
templateId = abc.Id;
} else if (c.Product__c.equals('Fibernet') || c.Product__c.equals('Lite')){
templateId = efg.Id;
} else if (c.Product__c.contains('Hosted') || c.Product__c.contains('Domain')){
templateId = domainX.Id;
} else if (c.Product__c.contains('EVPL')){
templateId = evpl.Id;
}
}
else
{
System.debug('-----inside-isWholesale-true------------->'+c.Product__c);
if (c.Product__c.contains('abc')) {
templateId = DDosWS.Id;
} else if (c.Product__c.equals('Fibernet') || c.Product__c.equals('Lite')){
templateId = fiberWS.Id;
} else if (c.Product__c.contains('EVPL')){
templateId = evplWS.Id;
}
}
What is the error you are getting,
Also execute the below code and print the deug log here:
Regards,
Mahesh