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
streetstreet 

Bulkification of below code.

trigger UpdateTenantAllocation on Tenant_Allocations__c (after update)
{
public list<Invoice_and_Billing_Detail__c> INVBD {get;set;}
INVBD = new List<Invoice_and_Billing_Detail__c>();

for(Tenant_Allocations__c t:trigger.new)
{

Location__c l1=[select id,Bill_Tenants__c from location__c where id=:t.Location_new__c];

system.debug('............'+l1);

Invoice_and_Billing_Detail__c[] lb=[select id,Rate__c, name,Location1__c from Invoice_and_Billing_Detail__c where Location1__c=:l1.id and QB_Txn_ID__c=null ];
system.debug('............'+lb);

for(Invoice_and_Billing_Detail__c lb1:lb){

if(l1.Bill_Tenants__c==true)
{
lb1.Rate__c=t.Next_Period_Invoice_Amount__c;

}
else
{
lb1.Rate__c=222;

}
INVBD.add(lb1);

}

update INVBD;
system.debug('............'+lb);
}
}

All Answers

Abhay AroraAbhay Arora

please dont post duplicate issues so that you can get solution easily