Portal filtering - only show most recent related record
I am working on a database that currently stores 3 contract-like files in separate container fields of each contracted entity's record. The way it is presently built, newly imported copies of these files overwrite the old ones. I have been asked to upgrade the database so that it will retain previous copies.
I have created another table to store one of those document types in, and am relating the documents to the entities based on the entity record #. (Fortunately for me, documents are only associated with a single entity). Viewing and accessing all related items via a portal works perfectly. However, I have also been asked to only display the most recent version of each document in the primary layout.
Each document has an auto-entered creation and mod timestamp, so I've tried filtering the portal using those fields. Per the help article at http://help.filemaker.com/app/answers/detail/a_id/7557/~/portal-filtering-introduced-in-filemaker-pro-11 , I have tried:
If ( Contracts::Creation Date = Last ( Contracts::Creation Date ) ; 1 ; 0 )
If (Last ( Contracts::Creation Date ) ; 1 ; 0 )
Last ( Contracts::Creation Date )
... as my filter terms, but the portal still shows me all related records. Perhaps my syntax is off? I also thought that perhaps the portal just wasn't updating correctly, but adding (and clicking) a Refresh Window button didn't make any difference. I've also tried making sure the Contracts table is sorted by Creation Date, just in its own layout view and in the relationship settings, to no avail. I am using FMPA 11, but the file I'm working on resides on a server currently running FMS 10. However, copying it locally to my desktop and opening it directly in FMPA 11 instead of from the server produced the same behavior.
I managed to find one other related help article at http://help.filemaker.com/app/answers/detail/a_id/2923/~/showing-only-the-most-recently-added-portal-rows stating, "Showing the most recently added related record can be done easily with a calculation and the Last function. However, if you want to show the last two or three related records in a portal then the task becomes more difficult. In this case, you'll need to use a script to accomplish the task." -- it proceeds to go into detail about how to do the latter, and I can't find information about only showing the most recently added record! Apparently that is too easy to bother detailing but still beyond me.
Any help would be greatly appreciated..