Hi All,
In Last post we discussed how can we optimiza SOQL and DML in our triggers. But there are cases where we do not use SOQL in loop still we face such issue. Following are the such cases
1) Bulk upload
2) Cyclic Trigger Invocation : When we have bigger triggers that have more then one SOQL and dml statements, again it might be posible that dml in one trigger invoke another trigger and again that trigger invoke some other.
3)Some time we have custom pages where we save more then one object in a single instance in that case triggers of all the object are also invoked in single instance.
Now to solve these issues we need to write triggers in a structured manner with taking care of order of execution of trigger.Before going ahead first we need to be familiar with some Trigger Context Variables
In Last post we discussed how can we optimiza SOQL and DML in our triggers. But there are cases where we do not use SOQL in loop still we face such issue. Following are the such cases
1) Bulk upload
2) Cyclic Trigger Invocation : When we have bigger triggers that have more then one SOQL and dml statements, again it might be posible that dml in one trigger invoke another trigger and again that trigger invoke some other.
3)Some time we have custom pages where we save more then one object in a single instance in that case triggers of all the object are also invoked in single instance.
Now to solve these issues we need to write triggers in a structured manner with taking care of order of execution of trigger.Before going ahead first we need to be familiar with some Trigger Context Variables
Variable | Description |
isInsert | Returns true if this trigger was fired due to an insert operation, from the Salesforce user interface, Apex, or the API. |
isUpdate | Returns true if this trigger was fired due to an update operation, from the Salesforce user interface, Apex, or the API. |
isBefore | Returns true if this trigger was fired before any record was saved. |
isAfter | Returns true if this trigger was fired after all records were saved. |
isUndelete | Returns true if this trigger was fired after a record is recovered from the Recycle Bin (that is, after an undelete operation from the Salesforce user interface, Apex, or the API.) |
Regards
No comments:
Post a Comment