AnsweredAssumed Answered

Bug in Filemaker PHP

Question asked by unpocoloco89511 on Nov 16, 2016
Latest reply on Dec 9, 2016 by unpocoloco89511

I just did my first development using PHP to access our master FM app and came across an interesting phenomenon. The FM table I was trying to update has several number fields in which I store boolean values and I was trying set one of these fields to 1. The statement looked like this:

 

$billing_address_rec->setField("@_isMailing?", !$mail_switch );

 

where $mail_switch is a boolean value indicating whether the billing address is also the mailing address. Using a logical inversion of a boolean variable within a function/method call is simply basic PHP, so I was shocked to find that this field never got set to 1 when it was clearly supposed to.

 

When I started debugging and examined the contents of $billing_address_rec before the commit(), it had a "1" in the "@_isMailing?" field just like it should. However, after the commit(), I re-examined the record and "@_isMailing?"  had no value in it. No matter what I tried to do, it kept failing until I finally forced the value to a 1 using a numeric constant:

 

$billing_address_rec->setField("@_isMailing?", 1 );

 

So my workaround ended up being:

 

if( $mail_switch )

       $billing_address_rec->setField( "@_isMailing?", 0 );

else

      $billing_address_rec->setField( "@_isMailing?", 1 );

 

The weird thing is that I use PHP variables to load all my other fields with total success, so it appears that there is some problem having to do with the logical inversion "!" process taking place within the FM method call.

Outcomes