You need to sign in to do that
Don't have an account?
Travis Wright
Another set of Eyes on my Apex trigger
The following trigger is not eveluating past the Prospect Major for some reason. If I comment out the major assignment I get Mid for an account that should be Inside. I am hoping I am missing something small as I need to reassign accounts this evening after 5pm EST. I am sure there is a better way to do it so I am sorry for all the over code.
trigger AssignTerritoryType on Account (Before insert, Before update) {
For (Account a :trigger.new){
IF((a.Current_Account_Status__c == 'Customer' ||
a.Current_Account_Status__c == 'Customer - In Play') &&
a.NumberOfEmployees >= 10000 )
{ a.Major__c=true;
a.Mid__c=False;
a.Inside__c=False;
}
else IF((a.Current_Account_Status__c == 'Customer' ||
a.Current_Account_Status__c == 'Customer - In Play') &&
(a.NumberOfEmployees > 2000 &&
a.NumberOfEmployees <= 10000))
{ a.Major__c=False;
a.Mid__c=True;
a.Inside__c=False;
}
else IF((a.Current_Account_Status__c == 'Customer' ||
a.Current_Account_Status__c == 'Customer - In Play') &&
(a.NumberOfEmployees > 0 &&
a.NumberOfEmployees <= 2000))
{a.Major__c=False;
a.Mid__c=False;
a.Inside__c=True;
}
else if((a.Current_Account_Status__c == 'Prospect' ||
a.Current_Account_Status__c == 'Prospect - In Play' &&
(a.Fortune_1000_Rank__c==NULL) &&
(a.NumberOfEmployees >= 9000) &&
(a.Industry != 'Education')==True) ||
(a.Current_Account_Status__c == 'Prospect' ||
a.Current_Account_Status__c == 'Prospect - In Play' &&
(a.Fortune_1000_Rank__c==Null) &&
(a.AnnualRevenue >= 1000000000) &&
(a.Industry != 'Education')==True) ||
(a.Current_Account_Status__c == 'Prospect' ||
a.Current_Account_Status__c == 'Prospect - In Play' &&
a.Industry == 'Pharma/BioTech') ||
(a.Current_Account_Status__c == 'Prospect' ||
a.Current_Account_Status__c == 'Prospect - In Play' &&
a.Industry == 'Fed - Gov') ||
(a.Current_Account_Status__c == 'Prospect' ||
a.Current_Account_Status__c == 'Prospect - In Play' &&
a.Fortune_1000_Rank__c <=750 ))
{
a.Major__c=true;
a.Mid__c=False;
a.Inside__c=False;
}
else if ((a.Current_Account_Status__c == 'Prospect' ||
a.Current_Account_Status__c == 'Prospect - In Play' &&
(a.NumberOfEmployees < 9000) &&
(a.NumberOfEmployees >=3000) &&
(a.Industry != 'Education')==True ) ||
(a.Current_Account_Status__c == 'Prospect' ||
a.Current_Account_Status__c == 'Prospect - In Play' &&
(a.AnnualRevenue < 1000000000) &&
(a.AnnualRevenue >=500000000)) ||
(a.Current_Account_Status__c == 'Prospect' ||
a.Current_Account_Status__c == 'Prospect - In Play' &&
(a.Fortune_1000_Rank__c >=751)) ||
(a.Current_Account_Status__c == 'Prospect' ||
a.Current_Account_Status__c == 'Prospect - In Play' &&
(a.NumberOfEmployees >=8000) &&
(a.Industry == 'Education')==True) ||
(a.Current_Account_Status__c == 'Prospect' ||
a.Current_Account_Status__c == 'Prospect - In Play' &&
a.Industry == 'State -Gov')
)
{a.Major__c=False;
a.Mid__c=True;
a.Inside__c=False;
}
else
{a.Major__c=False;
a.Mid__c=False;
a.Inside__c=True;
}
}
}
trigger AssignTerritoryType on Account (Before insert, Before update) {
For (Account a :trigger.new){
IF((a.Current_Account_Status__c == 'Customer' ||
a.Current_Account_Status__c == 'Customer - In Play') &&
a.NumberOfEmployees >= 10000 )
{ a.Major__c=true;
a.Mid__c=False;
a.Inside__c=False;
}
else IF((a.Current_Account_Status__c == 'Customer' ||
a.Current_Account_Status__c == 'Customer - In Play') &&
(a.NumberOfEmployees > 2000 &&
a.NumberOfEmployees <= 10000))
{ a.Major__c=False;
a.Mid__c=True;
a.Inside__c=False;
}
else IF((a.Current_Account_Status__c == 'Customer' ||
a.Current_Account_Status__c == 'Customer - In Play') &&
(a.NumberOfEmployees > 0 &&
a.NumberOfEmployees <= 2000))
{a.Major__c=False;
a.Mid__c=False;
a.Inside__c=True;
}
else if((a.Current_Account_Status__c == 'Prospect' ||
a.Current_Account_Status__c == 'Prospect - In Play' &&
(a.Fortune_1000_Rank__c==NULL) &&
(a.NumberOfEmployees >= 9000) &&
(a.Industry != 'Education')==True) ||
(a.Current_Account_Status__c == 'Prospect' ||
a.Current_Account_Status__c == 'Prospect - In Play' &&
(a.Fortune_1000_Rank__c==Null) &&
(a.AnnualRevenue >= 1000000000) &&
(a.Industry != 'Education')==True) ||
(a.Current_Account_Status__c == 'Prospect' ||
a.Current_Account_Status__c == 'Prospect - In Play' &&
a.Industry == 'Pharma/BioTech') ||
(a.Current_Account_Status__c == 'Prospect' ||
a.Current_Account_Status__c == 'Prospect - In Play' &&
a.Industry == 'Fed - Gov') ||
(a.Current_Account_Status__c == 'Prospect' ||
a.Current_Account_Status__c == 'Prospect - In Play' &&
a.Fortune_1000_Rank__c <=750 ))
{
a.Major__c=true;
a.Mid__c=False;
a.Inside__c=False;
}
else if ((a.Current_Account_Status__c == 'Prospect' ||
a.Current_Account_Status__c == 'Prospect - In Play' &&
(a.NumberOfEmployees < 9000) &&
(a.NumberOfEmployees >=3000) &&
(a.Industry != 'Education')==True ) ||
(a.Current_Account_Status__c == 'Prospect' ||
a.Current_Account_Status__c == 'Prospect - In Play' &&
(a.AnnualRevenue < 1000000000) &&
(a.AnnualRevenue >=500000000)) ||
(a.Current_Account_Status__c == 'Prospect' ||
a.Current_Account_Status__c == 'Prospect - In Play' &&
(a.Fortune_1000_Rank__c >=751)) ||
(a.Current_Account_Status__c == 'Prospect' ||
a.Current_Account_Status__c == 'Prospect - In Play' &&
(a.NumberOfEmployees >=8000) &&
(a.Industry == 'Education')==True) ||
(a.Current_Account_Status__c == 'Prospect' ||
a.Current_Account_Status__c == 'Prospect - In Play' &&
a.Industry == 'State -Gov')
)
{a.Major__c=False;
a.Mid__c=True;
a.Inside__c=False;
}
else
{a.Major__c=False;
a.Mid__c=False;
a.Inside__c=True;
}
}
}
a.Current_Account_Status__c == 'Prospect - In Play'". It may have something to do with the conditions.
All Answers
a.Current_Account_Status__c == 'Prospect - In Play'". It may have something to do with the conditions.