+ Start a Discussion
Jean-Noel CasassusJean-Noel Casassus 

bulk annotation in trigger

Hello,

bulk as an annotation look like to be permitted in a trigger, is there any documentation on the purpose of it ?

For instance, the 2 following are valid
trigger AccountTrigger on Account bulk (before insert){
// Do something
}
trigger AccountTrigger on Account  (before insert){
// Do something
}
Ishwar ShindeIshwar Shinde
Hi,

In bulkification of trigger, you need to ensure that it will run in multiple records passed to it in chunk. There is no annotation for it. For more details on bukify code pls visit - https://developer.salesforce.com/page/Best_Practice%3A_Bulkify_Your_Code
Vasani ParthVasani Parth
Hi Jean,

What are you trying to achieve ?

An Apex annotation modifies the way that a method or class is used, similar to annotations in Java. Annotations are defined with an initial @ symbol, followed by the appropriate keyword. To add an annotation to a method, specify it immediately before the method or class definition. For example:
global class MyClass {
     @future
     Public static void myMethod(String a)
     {
          //long-running Apex code
     }
}
There are various other annotations that you can use as per the requirement.

Please mark this as the best answer if this helps
 
Jean-Noel CasassusJean-Noel Casassus
Sorry guys but the question is to know what is the purpose of using bulk when creating / updating a trigger.
I can't find any documentation about it and it's a valid way of using a trigger.

trigger AccountTrigger on Account bulk (before insert){
// Do something
}
 
Ishwar ShindeIshwar Shinde
This will help you - https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_bestpract.htm
Jean-Noel CasassusJean-Noel Casassus
Ishwar Shinde, the question is not to have link to best practice, it's to know the purpose of the bulk keyword that can be used when creating / updating a trigger. I can't find any documentation to that particular keyword.

A standard trigger is something like :

trigger AccountTrigger on Account  (before insert){
// Do something
}

You can also use the following, please note the part in bold

trigger AccountTrigger on Account bulk (before insert){
// Do something
}

That's the purpose of bulk that I'm after over here.