Salesforce Fact #724 | Update related records other the latest one
Suppose we have a scenario where we need to update the related records for a parent record other than the latest child record. So, we can use for each loop to iterate over the records after retrieving them in descending order of createddate.
Since a collection cannot be modified while being iterated, we need to get the child records collections in a list and then remove the first record, else it would not remove the first child record from the list.
Note: The code snippet is only for demonstration purpose.
Attached are the screenshots.
Comments
Post a Comment