You need to sign in to do that
Don't have an account?
Not able to find the error in the below Trailhead/projects/QuickStart Apex/Add method to a class module.
This is a standard code from trailhead module when I copy paste on developer console i get an error.
Trailhead Code

Still not able to resolve the problem. Kindly requesting to please help me identifying the mistake and propbable solution.
Thanks!
Trailhead Code
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; }I have manipulated the above code to debug the errors with below code statements
Still not able to resolve the problem. Kindly requesting to please help me identifying the mistake and propbable solution.
Thanks!
Follow the below steps
1.Create the class with name "OlderAccountsUtility"
2.Copy the below code insde the class
your overall code should look like as below
Regards
Jay
Please mark as best answer if it helps you
you got this error because you try to write code in direct class body you can not write code in class body in the updateOlderAccounts class create a method and then save it
thanks
i hope it helps you let me inform if it helps you :)