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
VancouverDevVancouverDev 

Unexpected tokens

Hi everyone,

Running into issues with this code. It's just supposed to respond to different SIC with different values to be put in the Segment field.
trigger UpdateAccountSegment on Account (after update) {
List<String> segment() = new List<String>();
for (Account a : Trigger.new){
IF( 
a.Sic ='8211' || 
a.Sic ='8221' || 
a.Sic ='8222' || 
a.Sic ='8231' || 
a.Sic ='8243' || 
a.Sic ='8244' || 
a.Sic ='8249' || 
a.Sic ='8299' || 
a.Sic ='9111' || 
a.Sic ='9121' || 
a.Sic ='9131' || 
a.Sic ='9199' || 
a.Sic ='9211' || 
a.Sic ='9221' || 
a.Sic ='9222' || 
a.Sic ='9223' || 
a.Sic ='9224' || 
a.Sic ='9229' || 
a.Sic ='9311' || 
a.Sic ='9411' || 
a.Sic ='9431' || 
a.Sic ='9441' || 
a.Sic ='9451' || 
a.Sic ='9511' || 
a.Sic ='9512' || 
a.Sic ='9531' || 
a.Sic ='9532' || 
a.Sic ='9611' || 
a.Sic ='9621' || 
a.Sic ='9631' || 
a.Sic ='9641' || 
a.Sic ='9651' || 
a.Sic ='9661' || 
a.Sic ='9711' || 
a.Sic ='9721'){ 
segment.add('Butter')
};
else if(a.Spend__c<500000 && a.Spend__c<>0){
segment.add('Avocado')
};
else if(a.Spend__c>=500000 && a.Spend__c<2000000){
segment.add('Toast')
};
else if(a.Spend__c>=2000000 && a.Spend__c<10000000){
segment.add('Bagels')
};
else if(a.Spend__c>=10000000 && a.Spend__c<50000000){
segment.add('Donuts')
};
else if(a.SC_Addressable_Spend__c>=50000000){
segment.add('Pizza') 
};
else return
};
IF (segment=a.Account_Segmentation__c){
return
};
else {
a.Account_Segmentation__c=segment;
update a;
};
}

I'm getting the following errors:
Unexpected Token '<' at Line 2, for both <
And then "Extra ; at }" on 41, 44, 47, 50, 53, 56, 58, 61
And finally "Extra { at ;" on line 65

If anyone can provide editing help or tell me what I'm doing wrong I'd appreciate it!
Raj VakatiRaj Vakati
try this code
 
trigger UpdateAccountSegment on Account (after update) {
    List<String> segment = new List<String>();
    for (Account a : Trigger.new){
        IF( 
            a.Sic =='8211' || 
            a.Sic =='8221' || 
            a.Sic =='8222' || 
            a.Sic =='8231' || 
            a.Sic =='8243' || 
            a.Sic =='8244' || 
            a.Sic =='8249' || 
            a.Sic =='8299' || 
            a.Sic =='9111' || 
            a.Sic =='9121' || 
            a.Sic =='9131' || 
            a.Sic =='9199' || 
            a.Sic =='9211' || 
            a.Sic =='9221' || 
            a.Sic =='9222' || 
            a.Sic =='9223' || 
            a.Sic =='9224' || 
            a.Sic =='9229' || 
            a.Sic =='9311' || 
            a.Sic =='9411' || 
            a.Sic =='9431' || 
            a.Sic =='9441' || 
            a.Sic =='9451' || 
            a.Sic =='9511' || 
            a.Sic =='9512' || 
            a.Sic =='9531' || 
            a.Sic =='9532' || 
            a.Sic =='9611' || 
            a.Sic =='9621' || 
            a.Sic =='9631' || 
            a.Sic =='9641' || 
            a.Sic =='9651' || 
            a.Sic =='9661' || 
            a.Sic =='9711' || 
            a.Sic =='9721'){ 
                segment.add('Butter');
            }
        else if(a.Spend__c<500000 && a.Spend__c<>0){
            segment.add('Avocado');
        }
        else if(a.Spend__c>=500000 && a.Spend__c<2000000){
            segment.add('Toast');
        }
        else if(a.Spend__c>=2000000 && a.Spend__c<10000000){
            segment.add('Bagels');
        }
        else if(a.Spend__c>=10000000 && a.Spend__c<50000000){
            segment.add('Donuts');
        }
        else if(a.SC_Addressable_Spend__c>=50000000){
            segment.add('Pizza') ;
        }
        else {
            return;
        }
        if(segment[0]==a.Account_Segmentation__c){
            return;
        }
        else {
            a.Account_Segmentation__c=segment[0];
            update a;
        }
    }
}