function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Travis WrightTravis 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;
             }
       }
}
Best Answer chosen by Travis Wright
YuchenYuchen
I think you can try adding brackets around "a.Current_Account_Status__c == 'Prospect' || 
              a.Current_Account_Status__c == 'Prospect - In Play'". It may have something to do with the conditions.

All Answers

Travis WrightTravis Wright
Oh I forgot to mention if I change the Current account status to In Play it works just fine, So I know the issue is with the Prospect. I have checked the value and it is typed correctly. 
YuchenYuchen
I think you can try adding brackets around "a.Current_Account_Status__c == 'Prospect' || 
              a.Current_Account_Status__c == 'Prospect - In Play'". It may have something to do with the conditions.
This was selected as the best answer
Travis WrightTravis Wright
You are correct sir I noticed it just after updating it but thanks for look at it. Such a small mistake can cause such a big issue.