function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Churchill19Churchill19 

apex code to update parent record from MAX(date) of multiple children records? is it possible?

Hi,

i know its possible to do this in a Rollup Summary but wonder if it can be done in apex code? i.e.

Child Records                     End Date
-------------------                      ----------------
child1                                 12/06/2015
child2                                  06/05/2015
child3                                 18/06/2015


so the code would update a date field on parent with the max(End_Date__c) of the child record which the result would be "18/06/2015".

Thanks,

Sean.
Arunkumar RArunkumar R
Hi Churchill,

You can do it in apex by using Aggregate Query. 

https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_agg_functions.htm
ManojjenaManojjena
Hi Churchill,
You need to write a rollup summery trigger which should work for all after events .If you will send th object api name ,relationshipname ,field to which you need to update  from End_Date__c   .I will help you to write trigger to achieve this .