You need to sign in to do that
Don't have an account?
thekid12345
Batch Class on Account Contact Roles
global class AcrUpdateContact implements Database.Batchable<SObject>, Schedulable{ public Database.QueryLocator start(Database.BatchableContext BC) { //String query = 'SELECT ContactId FROM AccountContactRole WHERE Role := Primary Contact'; String query = 'Select Id, (SELECT ContactId,Role FROM AccountContactRoles WHERE Role =: Primary Contact) from Account WHERE Id IN(Select AccountID from AccountContactRole)'; return Database.getQueryLocator(query); } public void execute(Database.BatchableContext BC, List<Contact> cont) { for(Contact c : cont) { c.Status__c = 'Open'; system.debug(c); } update cont; } global void execute(SchedulableContext sc){ //Database.executeBatch(this); } global void finish(Database.BatchableContext BC) { } }The goal is when an account contact role is set to Primary Contact, update the associated Contact's status field to open. I know that account contact roles is very limited in that we can not trigger anything off of that object. Was wondering if the code above is correct.
Raj Vakati