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
nmnbawanmnbawa 

Help with the error message.

logontokartiklogontokartik

I am not sure why you are getting error but your code could be optimized to the below - 

trigger updateTaskStatus on Property__c (after update) 
{          
   Map<Id,String> taskMap = new Map<Id,String>();
   
   for(Property__c p : Trigger.new){
       if(p.status__c == 'Cancelled' || p.status__c == 'Expired')
               taskMap.put(p.Id,p.Status__c);   
   }            
                   
   List<Task> taskList = new List<Task>();
   For(Task t :  [select Id,WhatId,Status from Task where WhatId IN: taskMap.Keyset()])
            {
                t.Status='Completed';
                taskList.add(t);
            } 
                update taskList;   
} 

 

Yoganand GadekarYoganand Gadekar

Too many SOQL queries: 101 is a error u receive when u cross the maximum limit of 100 queries execution . This is a governer limit forced by salesforce to avoid monoploy in multitinnet environment and should not be crossed.

U should propably check for any "select" queries inside for loop in any other programs also.

SiddharthSiddharth

Your trigger seems to be going into resursive mode. Try putting a static variable to stop the recursive action. You can find this on SFDC help or also check if there is no other trigger being fired for related objects.