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
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
VamsiVamsi
Hi,

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;
    }
    
   
    
}

 
KapavariVenkatramanaKapavariVenkatramana

@Vamsi

 

Thanks a lot It worked.