You need to sign in to do that
Don't have an account?
Tillu
Below code is not executed properly ?
Hi,
I have a small problem while executing the If , else statements....
i am working with Contact,Territory objects...if contacts zip code matches with the condition Then correct territory record would need to be displayed on Contact.
Here is Condition...If contact's Account name is equals to Territory field Protect name Then the Territory record should be pulled on to contact. Otherwise other territory record need to be pulled on contact.
For below if/else at a time only one condition executed....when i remove else statement it ables to pull the matched one...
when i add the else it always executes else statement...even when it satisfies if statement....
try
{
if(tListForecare.size() > 0)
{
for(Territory__c t: tListForecare) //null create a map of State to territory. all go in this comparison
{
if(!ziplocked)
{
if(t.zip_start__c != null && t.zip_end__c != null && c.mailingPostalCode != null&&t.Protected_Accounts__c !=null)
{
if(t.Protected_Accounts__c.equals(aIBDMap.get(c.accountId).name)&&c.mailingPostalCode.substring(0,5) >= t.zip_start__c &&
c.mailingPostalCode.substring(0,5) <= t.zip_end__c)
{
c.Forecare_Territory__c = t.Id;
ziplocked = true;
}
else if(c.mailingState == t.state__c &&
(t.zip_start__c == null || t.zip_start__c == null) &&
t.Id!= null )
{
c.Forecare_Territory__c = t.Id;
}
}
}
}
I have a small problem while executing the If , else statements....
i am working with Contact,Territory objects...if contacts zip code matches with the condition Then correct territory record would need to be displayed on Contact.
Here is Condition...If contact's Account name is equals to Territory field Protect name Then the Territory record should be pulled on to contact. Otherwise other territory record need to be pulled on contact.
For below if/else at a time only one condition executed....when i remove else statement it ables to pull the matched one...
when i add the else it always executes else statement...even when it satisfies if statement....
try
{
if(tListForecare.size() > 0)
{
for(Territory__c t: tListForecare) //null create a map of State to territory. all go in this comparison
{
if(!ziplocked)
{
if(t.zip_start__c != null && t.zip_end__c != null && c.mailingPostalCode != null&&t.Protected_Accounts__c !=null)
{
if(t.Protected_Accounts__c.equals(aIBDMap.get(c.accountId).name)&&c.mailingPostalCode.substring(0,5) >= t.zip_start__c &&
c.mailingPostalCode.substring(0,5) <= t.zip_end__c)
{
c.Forecare_Territory__c = t.Id;
ziplocked = true;
}
else if(c.mailingState == t.state__c &&
(t.zip_start__c == null || t.zip_start__c == null) &&
t.Id!= null )
{
c.Forecare_Territory__c = t.Id;
}
}
}
}
for this t.Protected_Accounts__c.equals(aIBDMap.get(c.accountId).name)
for this : c.mailingPostalCode.substring(0,5) >= t.zip_start__c
and for this : c.mailingPostalCode.substring(0,5) <= t.zip_end__c