You need to sign in to do that
Don't have an account?
Max Prown 9
Button to mass update contacts from account
Hi,
I've created a button on the Account object that will update a field on the Account's Contact records that causes a trigger to fire. The code itself works fine when there are only a few contact records to be updated, but obviously in large batches it causes a delay and I wasn wondering if anyone had any tips for bulkifiying this type of solution Here's the code:
global with sharing class UpdateContactsButton{
public List<Contact> ConList {get;set;}
webService static String updateactcontacts(ID caseId){
List<Contact> ListToUpdate = new List<Contact>();
List<Contact> conlist = [SELECt ID, AccountID, Update_For_Workflow__c From Contact WHERE AccountId = :caseId];
For(Contact c : Conlist){
c.Update_For_Workflow__c = 'Selling Agreement Update' ;
ListToUpdate.add(c);
}
If(ListToUpdate.size() > 0){
update ListToUpdate;
}
return null;
}
}
Thanks in advance!
I've created a button on the Account object that will update a field on the Account's Contact records that causes a trigger to fire. The code itself works fine when there are only a few contact records to be updated, but obviously in large batches it causes a delay and I wasn wondering if anyone had any tips for bulkifiying this type of solution Here's the code:
global with sharing class UpdateContactsButton{
public List<Contact> ConList {get;set;}
webService static String updateactcontacts(ID caseId){
List<Contact> ListToUpdate = new List<Contact>();
List<Contact> conlist = [SELECt ID, AccountID, Update_For_Workflow__c From Contact WHERE AccountId = :caseId];
For(Contact c : Conlist){
c.Update_For_Workflow__c = 'Selling Agreement Update' ;
ListToUpdate.add(c);
}
If(ListToUpdate.size() > 0){
update ListToUpdate;
}
return null;
}
}
Thanks in advance!
Do you mean bulkifying for account updates and then its contacts subsequently?
Thanks
Siddharth
OSI Consulting
No this is only meant to update a field on Contacts that will kick off triggers for Contacts. I'm sure there are better ways of achieving this, but I wanted to see if this would provide a stop gap solution while we build out something more robust. Thanks!
Was just thinking if we can achieve this via Actions. Can we do that if possible
Thanks
Siddharth
OSI Consulting