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
sami31sami31 

Update date on parent record with date value on second child record

HI,
Address & Call (Child obj) have a lokup relation and i would like to udpate parent address field with value in Call_Date field of the second call on that address, we use Call_Date to determine the order of the call. I tried this with a batch job and queried all calls ordered by Call_Date in start method and did the update logic in execute(). But it is updating only few address records ignoring most of them. I think its because records returned by query are divided into batches of 200 records and they are executed independently (order is not guaranteed). Due to this 2 calls (on the same address) got split into different batches and they are processed as single call in the execute(), so the address is not updated with the Call_Date of 2nd call. 

How can we correct this? Is there a better solution to achieve this requirement.

Thanks.
jane1234jane1234
you can try with your same logic in trigger and in anonymous window u can do a mass update inchild record by creating a checkbox field to true