4 Replies Latest reply on Apr 27, 2015 5:03 AM by lukasb

    How to show all records in portal when date range fields are empty

    lukasb

      Title

      How to show all records in portal when date range fields are empty

      Post

      Hi all,

      I have a portal on a table A that shows records of table B within a date range. 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

      Is there a way for the portal to "show all" records when the global date fields are empty?

      Is there a way to "auto-reset" the global date fields and find them empty every time I visit my table A layout? (right now, it keep the last made date range search)

      I apologise if this is a question asked before but I cannot find the answer. If this is the case could someone share a link?

       

      Thanks you in advance,

      Lukas

        • 1. Re: How to show all records in portal when date range fields are empty
          philmodjunk

          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.

          • 2. Re: How to show all records in portal when date range fields are empty
            lukasb

            Hi Phil,

            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 ]

             

            Thanks Lukas

             

             

             

            • 3. Re: How to show all records in portal when date range fields are empty
              philmodjunk

              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.

              • 4. Re: How to show all records in portal when date range fields are empty
                lukasb

                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!!

                Thanks Phil!