Sort the relationship by Date Descending. Set up the calculations to use GetNthRecord. For DateField4 the calc would be GetNthRecord ( table::RecordedDate ; 4 )
You will have a similar view when you simply add a portal to your layout showing the records of Table::RecordedDate. Sorting of the portal has to be descending.
For the sort order to be correct for records with he same date you might also want to save the time (without the necessity to display it).
If you need to set those fields by script, so to have working relationships, I think that it will be better to create a value list*** populated by the values of the field: Table::RecordedDate.
The script could be something like:
Set Variable [ $v ; Value: ValueListItems ( Get ( FileName ) ; "theNameOfTheValueListInQuotes" ) ]
Set Field [ DateField1 ; GetValue ( $v ; ValueCount ( $v ) ) ]
Set Field [ DateField2 ; GetValue ( $v ; ValueCount ( $v ) - 1 ) ]
Set Field [ DateField3 ; GetValue ( $v ; ValueCount ( $v ) - 2 ) ]
Set Field [ DateField4 ; GetValue ( $v ; ValueCount ( $v ) - 3 ) ]
Set Field [ DateField5 ; GetValue ( $v ; ValueCount ( $v ) - 4 ) ]
*** the value list will automatically sort the dates ascending AND ABOVE ALL keep unique dates.
Thank you Ray for the script - I'm having "fun" as a newbie to FM (and its scripting) getting things to work!