I do this by running a script that collects the "start" and "end" global dates, and performs the find on my B table and then shows the results on my filtered portal of my A table.
How does that work? I can guess, but prefer not to. The scripted find seems unnecessary.
If you use this relationship:
TableA::anyField X TableB::anyfield
Any record in table A will match to all records in Table B.
You can then use a portal filter expression such as:
( IsEmpty ( TableA::globalDateStart ) and IsEmpty ( TableA::GlobalDateEnd ) ) or
( TableB::Date > TableA::GlobalDateStart and TableB::Date < TableA::GlobalDateEnd )
This will show all records in the specified date range or all records if both fields are empty. No scripted find is necessary.
To reset the global fields, set up a script with a pair of set field steps that set the fields to "" and use the OnLayoutEnter script trigger to perform that script.
Thanks for the answer,
I'm actually running 2 scripts. That's why I'm using scripting. One that searches by date range and one that searches by project within the same portal. (Could I have achieved this just by filtering the portal?)
Basically my filtered portal right now looks like this: (this is a simplified example)
And my find script goes like this:
The script for project find is very similar
And the relationship is like this:
Could this be done by just filtering the portal differently or is this the right way to go?
[The file in case anyone might want to check is here: https://dl.dropboxusercontent.com/u/34667031/date_range%20Copy.fmp12 ]
Your script has no effect on what records appear in the portal. Which appear is controlled by the relationship and your portal filter expression. Creating a found set on the clients invoices layout has no effect whatsoever on what records appear in a portal to clients invoices placed on the clients page layout.
Given the lack of "crows feet" in your screen shot, I don't see how you see more than one record at a time, if any in your portal as the screen shot shows what appears to be a "one to one" relationship between clients page and clients invoices.
I just realised what you mean!! I just put an OnObjectSave trigger, as you have instructed on another answer (http://forums.filemaker.com/posts/8c5e50a6a9?commentId=154788#154788 ) and It works very nicely!!