5 Replies Latest reply on Feb 10, 2016 10:07 AM by TSGal

    FileMaker PHP API - setResultLayout with Find Command

    fmdataweb

      I'm using setResultLayout for the first time so I can search on one layout with all the find fields on them but then switch to a much simpler layout with just the fields required for the search results. My search looks like this:

       

      $request = $fm->newFindCommand('WebSearch');
      $request->addFindCriterion('customerName', $_GET['contactName']);

      $request->setRange($skip, $max);

      // Set the layout to use for the Search Results
      $request->setResultLayout( 'WebSummaryList' );
         
      // Perform the Find
      $result = $request->execute();
         
      if (FileMaker::isError($result)) {
          if ($result->code = 401) {
          $findError = 'There are no Records that match that request: '. ' (' . $result->code . ')';
          } else {
          $findError = 'Find Error: '. $result->getMessage(). ' (' . $result->code . ')';
          }   

      } else {
      $records = $result->getRecords();
      }

      --

      I'm finding that when I include the line $request->setResultLayout( 'WebSummaryList' ) that my test for an error fails - if (FileMaker::isError($result)). I'm performing some finds with criteria that I know does not exist but the $findError variable is not getting populated (it returns 0 records). If I remove the line $request->setResultLayout( 'WebSummaryList' ) then the $findError variable is getting populated correctly.

       

      Can anyone see what I might be doing wrong or is this expected behaviour etc?

      thanks,

      Steve

        • 1. Re: FileMaker PHP API - setResultLayout with Find Command
          fmdataweb

          I've just run some tests by adding print_r($result) and here's what I get:

           

          - if I include $request->setResultLayout( 'WebSummaryList' ); as part of the find command request and perform a find that returns 0 records I get a FileMaker_Result Object

           

          - if I do NOT include $request->setResultLayout( 'WebSummaryList' ); as part of the find command request and perform a find that returns 0 records I get a FileMaker_Error Object

           

          In both cases the found set is 0. This at least explains why I'm not able to return the error when including setResultLayout.

           

          Can anyone else confirm this as well? Is this expected behaviour?

          • 2. Re: FileMaker PHP API - setResultLayout with Find Command
            TSGal

            fmdataweb:

             

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

             

            Another Community member has also encountered the same issue, and linked to this post.  I have attached your posts to the original report that went to Development and Testing for review.  When more information becomes available, I will let you know.

             

            TSGal

            FileMaker, Inc.

            • 3. Re: FileMaker PHP API - setResultLayout with Find Command
              TSGal

              fmdataweb:

               

              Testing has pointed me to page 71 of the Custom Web Publishing Guide, topic "Script execution order".  In essence, setResultLayout() is processed after find.

               

              https://fmhelp.filemaker.com/docs/14/en/fms14_cwp_guide.pdf

               

              TSGal

              FileMaker, Inc.

              • 4. Re: FileMaker PHP API - setResultLayout with Find Command
                user19752

                There is also written as

                If one of the above steps generates an error code, the request processing stops; any steps that follow are not executed.

                 

                but looks like forgetting stop processing to switch layout.

                • 5. Re: FileMaker PHP API - setResultLayout with Find Command
                  TSGal

                  fmdataweb:

                   

                  One of our testers gave me the following information:

                   

                  -----

                   

                  setResultLayout changes the response layout.  If setResultLayout() is used, then $layout parameter is used when processing a request, and switch to the layout specified by the -setResultLayout parameter when processing the response.  If there is an error on $layout, error object will not be returned while processing the response as the layout has already changed.  If you want to get an error object on 'Form View' layout, then FileMaker::isError should be called on the same layout and then change the layout.  For example:

                   

                  $request = $fm->newFindCommand('Form View');

                  $request->addFindCriterion('Title','xxxyyyzzz');

                   

                  // Perform the Find

                  $result = $request->execute();

                   

                  if (FileMaker::isError($result)) {

                    if ($result->code = 401) {

                    $findError = 'There are no Records that match that request: '.' (' . $result->code . ')';

                    } else {

                    $findError = 'Find Error: '. $result->getMessage(). ' (' . $result->code . ')';

                    }

                  }

                   

                  then perform setResultLayout('abc');

                   

                  -----

                   

                  TSGal

                  FileMaker, Inc.