+ Start a Discussion
Aishwarya P 4Aishwarya P 4 

The 'updateOlderAccounts' method did not update account records as expected

public class OlderAccountsUtility
    public static void updateOlderAccounts()
        List<Account> lstacc = [SELECT ID,Description FROM Account ORDER BY CreatedDate ASC LIMIT 5];
        for(Account acc : lstacc)
            acc.Description = 'Heritage Account';
        update lstacc;
        catch(exception e)

when i execute this code it is giving an error:
"Challenge Not yet complete... here's what's wrong: 
The 'updateOlderAccounts' method did not update account records as expected "

PLease help me with this
Amit Chaudhary 8Amit Chaudhary 8
Please check below post for same issue
1) https://developer.salesforce.com/forums/?id=906F0000000DCoXIAW
2) https://developer.salesforce.com/forums/?id=906F0000000BaFQIA0
public class OlderAccountsUtility {
	public static void updateOlderAccounts() {
		// Get the 5 oldest accounts
		Account[] oldAccounts = [SELECT Id, Description FROM Account ORDER BY CreatedDate ASC LIMIT 5];
		// loop through them and update the Description field
		for (Account acct : oldAccounts) {
			acct.Description = 'Heritage Account';
	   // save the change you made
	   update oldAccounts;
Let us know if this will help you
Trailhead StrangerTrailhead Stranger
Thanks for the code Amit Chaudhary 8, It worked for me. 
Apeksha AdoorApeksha Adoor
Thank you this helped me