1 2 Previous Next 18 Replies Latest reply on Dec 18, 2011 1:46 PM by dloughlin

    Filemaker API setOmit()

    dloughlin

      When trying to use this, I continually get "Fatal error: Call to undefined method FileMaker_Command_Find::setOmit()". Im my searches on the web, I keep seeing void mentioned. Is this no longer valid to use? If it is no longer valid, is there an alternative? If there is not, I would consider that a major limitation of the API.

       

      Dennis Loughlin

        • 1. Re: Filemaker API setOmit()
          mbraendle

          We don't have enough information. Do you use newCompoundFindCommand? setOmit is supposed to work with this one.

           

          Example:

           

          $compfind = $fm->newCompoundFindCommand('your layout');

          $findrequest1 = $compfind->addFindCriterion('field1','value1');

          $compfind->add(1,$findrequest1);

           

          $findrequest2 = $compfind->addFindCriterion('field2', 'value2');

          $findrequest2->setOmit();

          $compfind->add(2,$findrequest2);

           

          $result = $compfind->execute();

          • 2. Re: Filemaker API setOmit()
            dloughlin

            Yes I am using the newCompoundFindCommand. Is anyone using the sortOmit() successfully?

            • 3. Re: Filemaker API setOmit()
              mbraendle

              Just extended my message before with an example, have a look there.

              • 4. Re: Filemaker API setOmit()
                dloughlin

                Is that a currently working script? Those are the basic steps that I am following, although the script is much more complex. Should I take your responses (which I sincerely appreciate), to mean that you are successfully using the setOmit() with Filemaker API?

                • 5. Re: Filemaker API setOmit()
                  Romain

                  I think your missing a line, you need to declare findrequest1 and findrequest2 using newFindRequest first :

                   

                  $compfind = $fm->newCompoundFindCommand('your layout');

                  $findrequest1 = $fm->newFindRequest('your layout');

                  $findrequest1 = $compfind->addFindCriterion('field1','value1');

                  $compfind->add(1,$findrequest1);

                   

                  $findrequest2 = $fm->newFindRequest('your layout');

                  $findrequest2 = $compfind->addFindCriterion('field2', 'value2');

                  $findrequest2->setOmit();

                  $compfind->add(2,$findrequest2);

                   

                  $result = $compfind->execute();

                  • 6. Re: Filemaker API setOmit()
                    mbraendle

                    armoi, yes you are correct.

                     

                    In the meantime I have written a small PHP page with which you can test the behaviour:

                     

                    http://www.infochembio.ethz.ch/test/test.php   --> 343 books

                    http://www.infochembio.ethz.ch/test/test.php?omit --> 66 books

                     

                    The PHP is included here:

                     

                    <?php

                    error_reporting(E_ERROR);

                    ini_set('display_errors', 'on');

                    include_once('./libs/filemaker/FileMaker.php');

                    include_once('fm_config.php');

                     

                    if (array_key_exists('omit', $_REQUEST)) {

                      $omit = true;

                    } else {

                      $omit=false;

                    }

                     

                     

                    $fm = new FileMaker('Katalog',C_FM_HOST,C_FM_USER,C_FM_PASSWORD);

                    $compfind = $fm->newCompoundFindCommand('WWW_Results');

                     

                    $findrequest1 = $fm->newFindRequest('WWW_Results');

                    $findrequest1->addFindCriterion('Urheber','Atkins');

                    $compfind->add(1, $findrequest1);

                     

                    $findrequest2 = $fm->newFindRequest('WWW_Results');

                    $findrequest2->addFindCriterion('Titel','Physical Chemistry');

                    $findrequest2->setOmit($omit);

                    $compfind->add(2, $findrequest2);

                     

                    $compfind->setRange(0,1000);

                    $result = $compfind->execute();

                     

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

                      $error_code = $result->getCode();

                      if ($error_code == 401) {

                        header('Content-type: text/xml');

                        echo '<?xml version="1.0" encoding="UTF-8"?><lecturers count="0"/>';

                      } else {

                        echo 'A FileMaker Error occured: Code'.$error_code.'<br/>';

                        echo $result->getErrorString().'<br/>';

                        echo $result->getMessage();

                      }

                      die();

                    }

                     

                    $records = $result->getRecords();

                    $count = $result->getFoundSetCount();

                    header('Content-type: text/xml');

                    echo '<?xml version="1.0" encoding="UTF-8"?>';

                    echo '<books count="' . $count . '">';

                    foreach ($records as $record) {

                     

                      echo '<book title="' . $record->getField('Titel') . '" author="' . $record->getField('Urheber') . '" />';

                    }

                    echo '</books>';

                    ?>

                    • 7. Re: Filemaker API setOmit()
                      dloughlin

                      what is

                      include_once('fm_config.php');

                      I haven't been using this. Is it possible that could be my problem? I woudln't expect it is, as everything else i've been doing with the API has been working OK.

                      • 8. Re: Filemaker API setOmit()
                        mbraendle

                        No problem, I just define the host and the account / password in this file.

                        Best regards,

                         

                        Martin

                        • 9. Re: Filemaker API setOmit()
                          dloughlin

                          Thanks again for all your replies. I'll keep plugging at the problem. Are you using the API that came with Server 11 advanced?

                          • 10. Re: Filemaker API setOmit()
                            mbraendle

                            Yes, I use the FMSA 11 PHP API.

                            • 11. Re: Filemaker API setOmit()
                              dloughlin

                              I've simplified my script to troubleshoot this problem as follow:s

                               

                               

                              $omit =TRUE;   

                              $compoundFind  =$fm->newCompoundFindCommand($whichdb); 

                              $findCommand ->addFindCriterion ( 'Status', 'Active' );  

                              $compoundFind ->add(1,$findCommand);

                              $findCommand1=$fm->newFindCommand($whichdb);

                              $findCommand1 ->addFindCriterion ( 'Grade', '8th' ); 

                              $findCommand1 ->setOmit($omit); 

                              $find_result= $compoundFind->execute ();

                               

                               

                               

                              I still get the error message

                              Fatal error: Call to undefined method FileMaker_Command_Find::setOmit() in C:\inetpub\wwwroot\submitsearch.php on line 163

                               

                              Line 163 refers to the line in the script containing setOmit

                              I must have a version problem or be missing a file, but I don't what that might be. If I do not use the setOmit, it works just fine

                               

                               

                               

                               

                               

                              $compoundFind ->add(2,$findCommand1); 

                               

                               

                               

                               

                               

                               

                               

                               

                               

                               

                               

                               

                               

                               

                              $findCommand  =$fm->newFindCommand($whichdb); 

                              • 12. Re: Filemaker API setOmit()
                                dloughlin

                                Sorry about that, it didn't paste well

                                 

                                 

                                I've simplified my script to troubleshoot this problem as follow:s

                                 

                                 

                                 

                                $omit =TRUE;   

                                 

                                 

                                 

                                $compoundFind  =$fm->newCompoundFindCommand($whichdb); 

                                $findCommand  =$fm->newFindCommand($whichdb); 

                                $findCommand ->addFindCriterion ( 'Status', 'Active' );     

                                $compoundFind ->add(1,$findCommand);

                                $findCommand1=$fm->newFindCommand($whichdb); 

                                $findCommand1 ->addFindCriterion ( 'Grade', '8th' );  

                                $findCommand1 ->setOmit($omit);

                                $compoundFind ->add(2,$findCommand1);  

                                $find_result= $compoundFind->execute ();

                                 

                                 

                                 

                                 

                                 

                                I still get the error message

                                 

                                Fatal error: Call to undefined method FileMaker_Command_Find::setOmit() in C:\inetpub\wwwroot\submitsearch.php on line 163

                                 

                                Line 163 refers to the line in the script containing setOmit

                                I must have a version problem or be missing a file, but I don't what that might be. If I do not use the setOmit, it works just fine

                                • 13. Re: Filemaker API setOmit()
                                  mbraendle

                                  Just compare your code with mine, and you will find the mistake. It starts with line 2.

                                  • 14. Re: Filemaker API setOmit()
                                    dloughlin

                                    I don't see any difference, and keep in mind, it works if I remove the setOmit line

                                    1 2 Previous Next