You need to sign in to do that
Don't have an account?
aj4
Apexx Trigger Limit when upload/update data through data loader or any other tool
Hi !
We have trigger on account object. which work fine when you save records.
But When we insert/update the record through data loader or any third party tool It through errors for governence limit.
I dont understand why it is throwing error when mass update ?
Isnt' when you update the record through data loader or any tool it save one record at a time. Can anyone clarify what is happening in this case.
Thanks in advance.
If you want to learn about the governor limits, check out the Apex Developer's Guide.
If it is a query causing the problem, gather the Salesforce Ids of all the triggered records first and put them into a collection. Query once using the collection of ids (outside of the loop) - you will get a list of objects as a result.
If it is a DML command causing the error, move the command outside of the loop. Instead of performing the command for every iteration of the loop, add the finished object to a list. After the loop has finished executing and has added all the objects to the list, pass the list through the DML command.
There are plenty of examples of avoiding governor limitations throughout these boards if you take a look around.
Also, you may want to check out this wiki post.
That being said, I have some triggers where the business logic is too complex to get the code to not set off the governor limits with inserts/updates coming in chunks of 200. In those cases, I go to the Settings in the Data Loader and reduce the Batch Size. I just use trial and error to figure out what the maximum batch size can be for the trigger I'm working with.
Agreed,
But there is limit on number of object stored in Collection. Can you add 100000 object in collection or list?
If you hvae 10000 records in SF Account object and trigger is for updating single field. say x.
The trigger will work fine in this stuation if you save the single record.
But when you upload the record with tools It create the problem. How will you breakdown the record chunk if there is limitation on Collection and list?
If you have sample code greatly appreciate.
Thanks