You need to sign in to do that
Don't have an account?
Churchill19
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.
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.
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
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 .