Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Toggle two fields

(0 reviews)

Say you’ve got two fields, both number fields, and you want to use them as flag fields, to be set to either 0 or 1. But they should always be opposite from each other. Changing one field should change the other and vice versa.

At first, that seems simple. You just need to make each field an auto-enter referencing the other field, right? Nope. That doesn’t work. FileMaker’s calculation engine does not like that sort of circular references. Field A changes so Field B changes so Field A changes, etc. Nothing terrible will happen, it just won’t work.

I played around with a couple ideas and the one that works is this:

Flag1 =

Let ( [ f1 = Flags::Flag1 Final ;
f2 = Flags::Flag2 Final ] ;
If ( $$f2.active ; not f2 & Let ( $$f2.active = “” ; “” ) ;
Let ( $$f1.active = True ; f1 ) ) )

 

Flag2 =

Let ( [ f1 = Flags::Flag1 Final ;
f2 = Flags::Flag2 Final ] ;
If ( $$f1.active ; not f1 & Let ( $$f1.active = “” ; “” ) ;
Let ( $$f2.active = True ; f2 ) ) )

 

You may wonder what the heck is going on here!

In short, two things. The field is checking to see if it’s the one that was edited, then editing itself based on that knowledge and then handling the $$variable that communicates that.

If [the other field was edited] then change this value to the opposite of that field and clean up the variable.

If [this field was edited] set the variable so the other field knows it’s being edited, and just set the field to itself.

Using Let() to define (and clean up) $$variables inside a calculation is not common, but is powerful and handy in certain situations.

Enjoy!

View the full article

0 Comments

Recommended Comments

There are no comments to display.

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.