You need to sign in to do that
Don't have an account?
Hi anyone please hel;p in writing test class for the trigger below,
trigger ContactSumTriggermodified on Contact (after delete, after insert, after update,after undelete)
{
Set<ID>conIds= new Set<ID>();
Contact[] cons;
if (Trigger.isDelete)
cons = Trigger.old;
else
cons = Trigger.new;
Set<ID> acctIds = new Set<ID>();
for (Contact con : cons)
{
acctIds.add(con.AccountId);
}
Map<ID, Account> acctsToUpdate = new Map<ID, Account>([Select Id,Total_no_of_contacts__c ,(Select Id,AccountId from Contacts where AccountId in :acctIds)from Account where Id in :acctIds]);
for(Contact con:[Select Id , AccountId from Contact where AccountId in:acctstoupdate.keyset()])
conIds.add(con.id);
for(Account acct:acctstoupdate.values())
{
if (acct.Total_no_of_contacts__c != conIds.size())
acct.Total_no_of_contacts__c = conIds.size();
}
update acctsToUpdate.values();
}
Just to begin with :
Thanks
Ankit Arora
Blog | Facebook | Blog Page
All Answers
Just to begin with :
Thanks
Ankit Arora
Blog | Facebook | Blog Page
Hi , i need to write a trigger on a object called "enroll candidate" which is associated with candidate object and course detail object , where course detail object is a child object of course object, my req is there is a field called as booked slot and totalslot , when total slot is entered, booked slot is calculated automatically , i need to inactivate or stop the condition where bookslot is equal to totalslot and also booked slot should be incremented by ++ through a bulk trigger . can anyone please help me with this