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
Soujanya Uppal 9Soujanya Uppal 9 

update account record on basis of the conditions

i am getting this error Missing ';' at '{' please help

list<Account> accList= [select id,name,billingcity,annualrevenue,industry,rating from Account];
list<account> accNew= new list<account>();
for(account ac:accList){
    if(ac.Billingcity=='Hyderabad')
        {
            ac.Rating='Hot';
        }
        elseif(ac.Billingcity=='Paris')
       {
            ac.Rating='Cold';
        }
        elseif(ac.Billingcity=='Austin')
       {
            ac.Rating='Warm';
        }
        elseif(ac.Billingcity=='Vizag')
       {
            ac.Rating='Yahoo';
        }       
        else(ac.Billingcity=='Other')
        {
            ac.Rating='Google';
        }
   
accNew.add(ac);    
    }
update accNew; 
Best Answer chosen by Soujanya Uppal 9
Suraj Tripathi 47Suraj Tripathi 47

Hi,

 

please use the below code.It is working fine.

list<Account> accList= [select id,name,billingcity,annualrevenue,industry,rating from Account];
list<account> accNew= new list<account>();
for(account ac:accList){
    if(ac.Billingcity=='Hyderabad')
        {
            ac.Rating='Hot';
        }
        else if(ac.Billingcity=='Paris')
       {
            ac.Rating='Cold';
        }
        else if(ac.Billingcity=='Austin')
       {
            ac.Rating='Warm';
        }
        else if(ac.Billingcity=='Vizag')
       {
            ac.Rating='Yahoo';
        }       
        else 
        {
            ac.Rating='Google';
        }
   
accNew.add(ac);    
    }
update accNew;
elseif is corrected to else if
Please mark it as the Best Answer if your query is solved.
thank You