You need to sign in to do that
Don't have an account?
anvesh@force.com
Both If and else statements executed at a time ?
https://developer.salesforce.com/forums/#!/feedtype=RECENT&criteria=ALLQUESTIONSI am facing a difficult issue...as If and else statements were executed at a time.The difficult is it was executed correctly in sand box and not
in production it was executed if and else statements at a time......after if statement it enters in to else statement.
for(Market_Metrics__c c: cIsBeforeAnnuity)
{
System.debug('tlistAnnuity'+tListAnnuity);
try
{
if(c.Exclude_from_Territory__c == false)
{
for(Territory__c t: tListAnnuity)
{
if(aIBDMap.get(c.SFDC_Account_Name__c) != null) //experimental code.
{
System.debug('AccountTest'+aIBDMap.get(c.SFDC_Account_Name__c).Name);
System.debug('ClsBefore'+cIsBeforeAnnuity);
System.debug('AccountChannel'+aIBDMap.get(c.SFDC_Account_Name__c).channel__c);
System.debug('Protected Accounts'+t.Protected_Accounts__c);
if(c.State__c== t.state__c && c.Zip_Code__c.substring(0,5) >= t.zip_start__c && c.Zip_Code__c.substring(0,5) <= t.zip_end__c && t.type__c =='Annuity' && aIBDMap.get(c.SFDC_Account_Name__c).Name == t.Protected_Accounts__c)
{
System.debug('EntryTest1'+t.Protected_Accounts__c);
c.Annuity_Territory__c = t.Id;
System.debug('The current ID is Pro ' + t.Id);
}
else
if(aIBDMap.get(c.SFDC_Account_Name__c) != null) //experimental code.
{
System.debug('ProtAcc'+t.Protected_Accounts__c);
if(c.State__c== t.state__c && c.Zip_Code__c.substring(0,5) >= t.zip_start__c &&
c.Zip_Code__c.substring(0,5) <= t.zip_end__c && aIBDMap.get(c.SFDC_Account_Name__c).channel__c == t.channel__c &&t.type__c =='Annuity'&&t.Protected_Accounts__c == null)
{
System.debug('Entry Test2'+t.Protected_Accounts__c);
c.Annuity_Territory__c = t.Id;
System.debug('The current ID is >>' + t.Id);
}
}
catch (System.Exception e)
{
System.debug(e.getMessage());
//c.addError('[Error AC] There was an unexpected error while saving the record, please Contact support for assistance');
}
}
in production it was executed if and else statements at a time......after if statement it enters in to else statement.
for(Market_Metrics__c c: cIsBeforeAnnuity)
{
System.debug('tlistAnnuity'+tListAnnuity);
try
{
if(c.Exclude_from_Territory__c == false)
{
for(Territory__c t: tListAnnuity)
{
if(aIBDMap.get(c.SFDC_Account_Name__c) != null) //experimental code.
{
System.debug('AccountTest'+aIBDMap.get(c.SFDC_Account_Name__c).Name);
System.debug('ClsBefore'+cIsBeforeAnnuity);
System.debug('AccountChannel'+aIBDMap.get(c.SFDC_Account_Name__c).channel__c);
System.debug('Protected Accounts'+t.Protected_Accounts__c);
if(c.State__c== t.state__c && c.Zip_Code__c.substring(0,5) >= t.zip_start__c && c.Zip_Code__c.substring(0,5) <= t.zip_end__c && t.type__c =='Annuity' && aIBDMap.get(c.SFDC_Account_Name__c).Name == t.Protected_Accounts__c)
{
System.debug('EntryTest1'+t.Protected_Accounts__c);
c.Annuity_Territory__c = t.Id;
System.debug('The current ID is Pro ' + t.Id);
}
else
if(aIBDMap.get(c.SFDC_Account_Name__c) != null) //experimental code.
{
System.debug('ProtAcc'+t.Protected_Accounts__c);
if(c.State__c== t.state__c && c.Zip_Code__c.substring(0,5) >= t.zip_start__c &&
c.Zip_Code__c.substring(0,5) <= t.zip_end__c && aIBDMap.get(c.SFDC_Account_Name__c).channel__c == t.channel__c &&t.type__c =='Annuity'&&t.Protected_Accounts__c == null)
{
System.debug('Entry Test2'+t.Protected_Accounts__c);
c.Annuity_Territory__c = t.Id;
System.debug('The current ID is >>' + t.Id);
}
}
catch (System.Exception e)
{
System.debug(e.getMessage());
//c.addError('[Error AC] There was an unexpected error while saving the record, please Contact support for assistance');
}
}
Thanks
Shashikant