5 Replies Latest reply on May 10, 2016 6:21 AM by TSGal

    PHP setRelatedSetsFilters Does Not Work

    tduell_1

      Summary

      PHP setRelatedSetsFilters Does Not Work

      Product

      FileMaker Server

      Version

      11

      Operating system version

      OS X or Windows

      Description of the issue

      I believe there is a bug with the PHP engine. I don't believe the function setRelatedSetsFilters works. No matter how I program the code to find the record(s), then filter the portal based on the Portal Setup dialog box for Sort portal records, it simply does not filter the portal records. I've had to resort to either forcing the portal to do what I want via the Table Occurrence, which means extra fields and extra TOG's, or using the Privilege Sets to filter the portal based on user Privileges. Here's an example of 1 of the snippets of code I tried (I tried many different ways to do this). What I'm doing here is navigating from a list page to a detail page using getRecordByID. Then I'm storing the related records in the $related_records variable. Next, I'm applying the filter on the layout. Finally, I'm displaying the related records using a foreach loop.

      <?php
      $record = $fm->getRecordByID("LayoutName", $_GET['id']);
      $related_records = $record->getRelatedSet('related_data');
      $related_records->setRelatedSetsFilters('layout', 10);
      foreach($related_records as $related_record)
      {
      $table_data .= '' . $related_record->getField('related_data::Text') . '';
      $table_data .= '

      ';
      }
      ?>

      I have also tried performing a direct search using the newFindAllCommand, then filtering the related records, finally executing the request. That does not work either. So I'm at a loss after so much trial and error that I believe the setRelatedSetsFilters does not work,

      Steps to reproduce the problem

      See description for code. I'll be more than happy to provide you with a sample database and code to test if you contact me.

      Expected result

      The related records should only show the records based on the filter for the Portal Setup.

      Actual result

      No filter is applied.

      Exact text of any error message(s) that appear

      No errors.

      Workaround

      The only workaround is to use a specific TOG or Privilege Set to filter the records.

        • 1. Re: PHP setRelatedSetsFilters Does Not Work
          TSGal

          tduell:

          Thank you for your post, and I apologize for the late reply.

          I have sent your entire post to our Development and Testing departments for further review.  I will keep you posted.  In case they ask for a sample database, and since you offered, please check your Inbox at the top of this page for instructions where to send the file.

          TSGal
          FileMaker, Inc.

          • 2. Re: PHP setRelatedSetsFilters Does Not Work
            TSGal

            tduell:

            Our Testing department has let me know that setRelatedSetsFilters function limits the number of related records returned. However, the Filter portal records setting in the Portal Setup dialog box is not supported for XML/PHP queries. Any calculation specified for the Filter portal records setting is ignored.

            TSGal
            FileMaker, Inc.

            • 3. Re: PHP setRelatedSetsFilters Does Not Work
              tduell_1

              Thanks for the update. You may want to update the PHP documentation with more specific information about how the setRelatedSetsFilters works and/or how it is intended to work if you are saying the Portal Setup settings are ignored. Note from the documentation below; using the 'layout' option is supposed to apply the settings in the Portal Setup dialog box. So the reality is that the only option that works is 'none' and 'layout' is currently ignored. At this point I would consider your response that this is a known bug with an unknown date of resolution.

              The filter limits the number of related records returned by respecting the settings specified in the FileMaker Pro Portal Setup dialog box.

              void setRelatedSetsFilters (string $relatedsetsfilter, [string $relatedsetsmax = null])
              • string $relatedsetsfilter: Specify one of these values to control filtering:
                • 'layout': Apply the settings specified in the FileMaker Pro Portal Setup dialog box. The records are sorted based on the sort defined in the Portal Setup dialog box, with the record set filtered to start with the specified "Initial row."
                • 'none': Return all related records in the portal without filtering or presorting them.
                • string $relatedsetsmax: If the "Show vertical scroll bar" setting is enabled in the Portal Setup dialog box, specify one of these values:
                  • an integer value: Return this maximum number of related records after the initial record.
                  • 'all': Return all of the related records in the portal. If "Show vertical scroll bar" is disabled, the Portal Setup dialog box's "Number of rows" setting determines the maximum number of related records to return.

              Todd Duell

              • 4. Re: PHP setRelatedSetsFilters Does Not Work
                TSGal

                tduell:

                I have also sent a request to our Documentation department.

                Please check your Inbox at the top of this page for additional information.

                TSGal
                FileMaker, Inc.

                • 5. Re: PHP setRelatedSetsFilters Does Not Work
                  TSGal

                  tduell:

                   

                  This is now documented on page 79 of the FileMaker Server 15 Custom Web Publishing Guide under the section "Limiting the portal rows returned by find requests".

                   

                  https://fmhelp.filemaker.com/docs/15/en/fms15_cwp_guide.pdf

                   

                  TSGal

                  FileMaker, Inc.