Fix aggregate lookup formulas post-model reform.

We were not updating the id to index map for case add for 'next' and 'prev'.
Parent/child determination was flawed for 'first' and 'last'.
Fix function references from the parent to child tables.

Function references were dependent on CollectionRecord.children arrays which were not updated.
We correct unit tests to exercise these paths.
Add test cases for formulas in attributes.
[Fixes #84052752] [Fixes #84069882] [Fixes #84108898] [Fixes #84146702]

Fix bugs in formulas introduced by model reform.

Fix next and prev formula functions so they work for parent collections, too.