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

Popular posts from this blog

Salesforce Fact #192 | Call batch apex from flow

Salesforce Fact #457 | Get current user role name in flow