+ Start a Discussion
Durgamba RayuduDurgamba Rayudu 

Trail head question -- Tune transactions - efficient queries

can somebody help on this. i finished all the other ones in this trail head. installed the package. first ine worked fine. 
challenge is : 
Edit the AllBadThings() method, as follows:
Replace the if statement with a Where clause
Move the update statement outside of the for loop
Rename the method AllGoodThings()
i changed as below
public class TrailLoop {      
       public static void AllGoodThings(Account a) {
        List<Task> allMyTasks = [Select Id, status, whatId From Task Where whatId = :a.id];
        for (Task t : allMyTasks) {
                t.status = 'Completed';
            update allMyTasks;
but it is failing with this error

Durgamba RayuduDurgamba Rayudu
User-added imageif i didn'r rename also getting error method not found

Better you give it a try in the new TrailHead play ground.Because I tried in my trail org and it allowed me to pass the challenge..

public class TrailLoop {
    //Here is a combined problem of a query that needs a filter
    //and a loop that continually calls out to the database
    public static void AllGoodThings(Account a) {
        List<Task> allMyTasks = [Select Id, status, whatId From Task where whatId=:a.id];
        for (Task t : allMyTasks) {
                t.status = 'Completed';
       update allMyTasks;




Thanks a lot It worked.