AnsweredAssumed Answered

FMS PHP API single omit find request is broken in compound find.

Question asked by gastewart on Aug 9, 2015
Latest reply on Aug 10, 2015 by disabled_ntaylor

Summary

FMS PHP API single omit find request is broken in compound find.

Product

FileMaker Server

Version

14, 13, 12

Operating system version

Windows / OSX

Description of the issue

The FMS PHP API builds an incorrect WPE XML find query when using a compound find with a single "omit" find request.

Steps to reproduce the problem

Use the following simple PHP compound find:

$database = 'postcodes';
$layout   = 'brief postcodes';

$fm = new FileMaker($database, $hostspec, $username, $password);

$compoundFindCommand = $fm->newCompoundFindCommand($layout);

$findRequest = $fm->newFindRequest($layout);
$findRequest->addFindCriterion('Pcode', '0810');
$findRequest->setOmit(TRUE);

$compoundFindCommand->add(1, $findRequest);

$result = $compoundFindCommand->execute();

Expected result

The compound find should return all records where 'Pcode' DOES NOT match '0810'.

The correct WPE XML find query for a single "omit" find request should be:

-db=postcodes&-lay=brief+postcodes&-q1=Pcode&-q1.value=0810&-query=!(q1)&-findquery

Actual result

The compound find actually returns all records where 'Pcode' matches '0810', the inverse of what is requested by setting 'omit'.

Sniffing the network traffic reveals that the WPE XML find query is built incorrectly by the FMS PHP API:

-db=postcodes&-lay=brief+postcodes&-q1=Pcode&-q1.value=0810&-query=(q1)&-findquery

Workaround

An unsatisfactory workaround is to use a compound find with two find requests, where the first is essentially a dummy "match all", and the second is the "omit" request.

e.g.
$compoundFindCommand = $fm->newCompoundFindCommand($layout);

$findRequest1 = $fm->newFindRequest($layout);
$findRequest1->addFindCriterion('Pcode', '>=0');

$findRequest2 = $fm->newFindRequest($layout);
$findRequest2->addFindCriterion('Pcode', '0810');
$findRequest2->setOmit(TRUE);

$compoundFindCommand->add(1, $findRequest1);
$compoundFindCommand->add(2, $findRequest2);

$result = $compoundFindCommand->execute();


The correct solution to this problem is to repair the FMS PHP API to construct the correct query.

Outcomes