Поиск…


Bulkification

Если вы выполняете строчную обработку в Salesforce, вы, вероятно, быстро достигнете предела губернатора. Это особенно верно для триггеров и вещей, которые срабатывают, когда вы их не ожидаете. Одним из документированных способов преодоления лимита губернатора является обобщение.

Примечание . Следующая информация основана на официальных документах Salesforce.

Bulkifying Apex code означает, что код правильно обрабатывает более одной записи за раз. Когда партия записей инициирует Apex, выполняется один экземпляр этого кода Apex, но этот экземпляр должен обрабатывать все записи в этой заданной партии.

Не заполнено:

trigger accountTestTrggr on Account (before insert, before update) 
{

   //This only handles the first record in the Trigger.new collection
   //But if more than 1 Account initiated this trigger, those additional records
   //will not be processed
   Account acct = Trigger.new[0];
   List<Contact> contacts = [select id, salutation, firstname, lastname, email 
              from Contact where accountId =&nbsp;:acct.Id];
   
}

Bulkified:

trigger accountTestTrggr on Account (before insert, before update) 
{
    List<String> accountNames = new List<String>{};
   //Loop through all records in the Trigger.new collection
   for(Account a: Trigger.new){
      //Concatenate the Name and billingState into the Description field
      a.Description = a.Name + ':' + a.BillingState
   }
}


Modified text is an extract of the original Stack Overflow Documentation
Лицензировано согласно CC BY-SA 3.0
Не связан с Stack Overflow