+ Start a Discussion
prasanth kumarprasanth kumar 

simple account update is not working. please help

hi i worte a simple update of record in account object using developer console.  i am getting this error:---   "unexpected token: account"   at line 4;

public class updatename {
    public updatename()
    {
        list<account> accs=[select name form account where name='GenePoint'];
        
        for(account a:accs)
        {
            a.name='Jaffa point';
        }
        update accs;
    }
    
}
Best Answer chosen by prasanth kumar
Himanshu ParasharHimanshu Parashar
Hi Prasanth,

Try Below code. you have a small typo.
 
public class updatename {
    public updatename()
    {
        list<account> accs=[select name from account where name='GenePoint'];
        
        for(account a:accs)
        {
            a.name='Jaffa point';
        }
        update accs;
    }
    
}

Thanks,
Himanshu

All Answers

Himanshu ParasharHimanshu Parashar
Hi Prasanth,

Try Below code. you have a small typo.
 
public class updatename {
    public updatename()
    {
        list<account> accs=[select name from account where name='GenePoint'];
        
        for(account a:accs)
        {
            a.name='Jaffa point';
        }
        update accs;
    }
    
}

Thanks,
Himanshu
This was selected as the best answer
nbknbk
Try with below code as highlited from developer console to update the account.

public class updatename {
    public updatename()
    {
        list<account> accs=[select name form account where name='GenePoint'];
        list<account> lstacc = new list<account>();
       
        for(account a:accs)
        {
            a.name='Jaffa point';
            lstacc.add(a);
        }
        update lstacc;

    }
    
}
prasanth kumarprasanth kumar
Thank you Himanshu Parashar.      

Dear amith, nbk,  the code is right but, i put 'form'   at this place we have put 'from'.    Thankyou for help..