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
SureshSuresh 

Governer Limits

Hi,

When  and where does Governer Limits Occur and how to overcome them.


Regards,
Suresh
sandeep sankhlasandeep sankhla
Hi Suresh,

There are many best practises which we should follow while coding in apex....there are many limits on everything and if you dont follow the best practises you may hit the limits...

So lets take an example..

there are certain limits on DML and SOQL which we do in our code...

Example 1:

If you do DML in a foor loop it may hit the limit...

For(Account objAcc : lstAccounts)
{
     objAcc .Name = 'Test';
     update objAcc;
}

You can only do 150 DML in one instance..so in this case if above loop will iterate more than 200 time it will hit the limit..

To overcome this limit as and best practise we can store all the objects on one list and then we can do one DML instead of 150..

see this code
list<Account> lstAcc = new list<Account>();
For(Account objAcc : lstAccounts)
{
     objAcc .Name = 'Test';
     lstAcc .add(objAcc);
}

update lstAcc ;

Please find all governor limits for apex in below link..

https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_gov_limits.htm

Let me know if you need more details..

P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.

Thanks,
Sandeep
Salesforce Certified Developer 
SureshSuresh
Hi  Sandeep,

Whenever a trigger fires for each action the limit will be 150  or it is different.

Regards,
Suresh. 
sandeep sankhlasandeep sankhla
Hi Suresh,

It will be same for one instance..it means when my trigger will be fire that time for one flow it will be 150...second time again if trigger will fire then it will reset..

Thanks,
Sandeep