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 

Getting a Save error: Expression cannot be assigned on my code and not sure why?

Here is the code that I am using sorry if it is not clean or hard to read new to development and haven't learned how to clean up the mess. 


trigger AssignTerritoryType on Account (before insert, before update) {
For (Account a :trigger.new){
  Set<string> majorIndustries = new Set<string>{'Pharma/BioTech', 'Energy', 'Fed - Gov' ,'State - Mid','Education'};
if ( (a.NumberOfEmployees >= 10000) ||
      (a.AnnualRevenue >= 500000000) ||
   (a.Fortune_500__c = true) ||
   ( (a.Fortune_500_1000__c = True) && (a.NumberOfEmployees >=10000) && (a.AnnualRevenue >= 500000000) ) || //note that even if a.Fortune_500_1000__c = False it'll fall if a.NumberOfEmplyees >=10000 is true or A.AnnualRevenue>=500000000 since it will meet a previous condidtion
   majorIndustries.contains(a.Industry) = 'Pharma/BioTech')
   {
  a.Major__c=true;
    }
if ( ((a.NumberOfEmployees < 10000) && (a.NumberOfEmployees >=4000)) ||
     ((a.AnnualRevenue > 500000000) && (a.AnnualRevenue <=250000000)) ||
     ((a.Fortune_501_1000__c = true) &&(a.NumberOfEmployees > 10000) && (a.AnnualRevenue > 500000000))||
     (majorIndustries.contains(a.Industry) = 'State - mid')||
     ((a.NumberOfEmployees >=8000) && (majorIndustries.contains(a.Industry) = 'Education')
     )
   )
   {  
  a.Mid__c=true;
}
if   ((a.NumberOfEmployees < 4000) && (a.NumberOfEmployees >=1500)
     )
   {
  a.Inside__c=true;
   }
If   ((a.NumberOfEmployees < 4000)
  )
   {
  a.Inside_small__c=true;
   }
}
}
Best Answer chosen by Travis Wright
Anil SavaliyaAnil Savaliya
Contains return boolean value,Make correction in Trigger logic like below example;

trigger AssignTerritoryType on Account (before insert, before update) {
For (Account a :trigger.new){
  Set<string> majorIndustries = new Set<string>{'Pharma/BioTech', 'Energy', 'Fed - Gov' ,'State - Mid','Education'};
if ( (a.NumberOfEmployees >= 10000) || (a.AnnualRevenue >= 500000000) || (a.Fortune_500__c = true) || ( (a.Fortune_500_1000__c = True) && (a.NumberOfEmployees >=10000) && (a.AnnualRevenue >= 500000000) ) || majorIndustries.contains('Energy') == True )
   {
  a.Major__c=true;
    }


}
}

All Answers

Anil SavaliyaAnil Savaliya
Contains return boolean value,Make correction in Trigger logic like below example;

trigger AssignTerritoryType on Account (before insert, before update) {
For (Account a :trigger.new){
  Set<string> majorIndustries = new Set<string>{'Pharma/BioTech', 'Energy', 'Fed - Gov' ,'State - Mid','Education'};
if ( (a.NumberOfEmployees >= 10000) || (a.AnnualRevenue >= 500000000) || (a.Fortune_500__c = true) || ( (a.Fortune_500_1000__c = True) && (a.NumberOfEmployees >=10000) && (a.AnnualRevenue >= 500000000) ) || majorIndustries.contains('Energy') == True )
   {
  a.Major__c=true;
    }


}
}
This was selected as the best answer
Travis WrightTravis Wright
Worked Great thanks Now I just have to create the workflow rules that will follow the rule and Assign the accounts out to the correct reps. 

Final Code 

trigger AssignTerritoryType on Account (before insert, before update) {
    For (Account a :trigger.new){
        Set<string> majorIndustries = new Set<string>{'Pharma/BioTech', 'Energy', 'Fed - Gov' ,'State - Mid','Education'};
if ( (a.NumberOfEmployees >= 10000) ||
      (a.AnnualRevenue >= 500000000) ||
   (a.Fortune_500__c = true) ||
   ( (a.Fortune_500_1000__c = True) && (a.NumberOfEmployees >=10000) && (a.AnnualRevenue >= 500000000) ) || //note that even if a.Fortune_500_1000__c = False it'll fall if a.NumberOfEmplyees >=10000 is true or A.AnnualRevenue>=500000000 since it will meet a previous condidtion
    majorIndustries.contains('Energy') == True )
    {
  a.Major__c=true;
    }
if ( ((a.NumberOfEmployees < 10000) && (a.NumberOfEmployees >=4000)) ||
     ((a.AnnualRevenue > 500000000) && (a.AnnualRevenue <=250000000)) ||
     ((a.Fortune_500_1000__c = true) &&(a.NumberOfEmployees > 10000) && (a.AnnualRevenue > 500000000))||
      (majorIndustries.contains('State - Mid')==True ||
     ((a.NumberOfEmployees >=8000) &&
     (majorIndustries.contains('Education')==True)
     )
      )
   )
   {   
  a.Mid__c=true;
    }
if   ((a.NumberOfEmployees < 4000) && (a.NumberOfEmployees >=1500)
     )
   {
  a.Inside__c=true;
   }
If   ((a.NumberOfEmployees < 4000)
     )
   {
  a.Inside_small__c=true;
   }
}
}