You need to sign in to do that
Don't have an account?
Claire Sunderland 1
LREngine rollup with multiple field results
I am an admin attempting to modify a prior LREngine class in our Salesforce to rollup activity records onto Leads. I want to only rollup activities that meet certain criteria and am able to do so fine with one criteria but when I add 2 criteria I get a 'Constructor not defined' error so it seems the code doesn't allow more than one field result entry. Does anyone know a way around that so I can add multiple criteria?
Code is below. I'm getting an error on the second critiera where 'RecordType = \'Demo\''
Code is below. I'm getting an error on the second critiera where 'RecordType = \'Demo\''
public class ActivityRollups { public static void doRollups(Task[] objects) { LREngine.Context ctx = new LREngine.Context(Lead.SobjectType, // parent object Task.SobjectType, // child object Schema.SObjectType.Task.fields.WhoID // relationship field name ); ctx.add( new LREngine.RollupSummaryField( Schema.SObjectType.Lead.fields.Demos_Attended__c, Schema.SObjectType.Task.fields.id, LREngine.RollupOperation.Count )); LREngine.Context ctxDemoAttended = new LREngine.Context(Lead.SobjectType, // parent object Task.SobjectType, // child object Schema.SObjectType.Task.fields.WhoID, // relationship field name 'Call_Status__c = \'Attended\'', // filter / field result 'RecordType = \'Demo\'' // filter / field result ); Sobject[] masters = LREngine.rollUp(ctx, objects); Sobject[] mastersDemoAttended = LREngine.rollUp(ctxDemoAttended, objects); updateRecords(masters); masters = null; updateRecords(mastersDemoAttended); mastersDemoAttended = null; } private static void updateRecords(Sobject[] pMasters) { try { update pMasters; } catch (System.DMLException ex) { String s = ex.getMessage(); if (s.containsIgnoreCase('FIELD_CUSTOM_VALIDATION_EXCEPTION') && !Trigger.IsDelete) { Trigger.New[0].addError( s.substring( s.indexof('FIELD_CUSTOM_VALIDATION_EXCEPTION')+35, s.indexof(': [') ) ); return; } else { throw ex; } } } }
Brian Romanowski
The filters should be combined into 1, not comma seperated. To filter on the record type name it should be RecordType.DeveloperName.