+ Start a Discussion
matthew.w.hampton.ax1837matthew.w.hampton.ax1837 

Sum/Count Help

Hello:

 

I have to custom objects - Service_Orders__c and Rep_Sales_Summary__c that are unrelated but share a common key (Service_Order__c.Release__c = Rep_Summary__c.Turf__r.Name)

 

What I am looking to do is the following:

 

1. Group Service_Order__c records by Release__c

 

2. If Release__c = Rep_Summary__c.Turf__r.Name, then:

   a. Rep_Summary__c.Video__c = sum(Service_Order__c.Video__c)

   a. Rep_Summary__c.Internet__c = sum(Service_Order__c.Internet__c)

 

   a. Rep_Summary__c.Access_Line__c = sum(Service_Order__c.Access_Line__c)

   a. Rep_Summary__c.Completed__c = sum(Service_Order__c.Video__c) IF Service_Order__c.Status_Description__c = 'Completed'

 

   a. Rep_Summary__c.Video__c = sum(Service_Order__c.Video__c) IF Service_Order__c.Status_Description__c = 'Cancelled'

 

I'm an intermediate APEX writer but cannot figure this one out.

 

Any help you can provide is appreciated.

 

Thanks,

 

Matt