Search This Blog

Tuesday, August 4, 2015

Updating CTAs

Every once in a while CTAs will fire which do not assign the correct assignee. Here is the script to update them

List<JBCXM__CTA__c> ctasToUpdate = [SELECT CreatedDate,Id,JBCXM__Account__c, Name, JBCXM__Account__r.OwnerID,JBCXM__Assignee__c,JBCXM__Type__c, JBCXM__Source__c FROM JBCXM__CTA__c where JBCXM__Source__c = 'Rules' and Name = 'CTA: Declining App Trend Two Weeks in a Row' and createddate = LAST_N_DAYS:2 and JBCXM__Assignee__c = '005G0000002efmLIAQ' order by CreatedDate desc limit 500];

for(JBCXM__CTA__c oneCTA: ctasToUpdate){
     oneCTA.JBCXM__Assignee__c = oneCTA.JBCXM__Account__r.OwnerID;
}

update ctasToUpdate;

No comments:

Post a Comment