On/Off (Boolean) Fields

I’m really enjoying my first forays into FM12 – many things seem much easier, and often more elegant.

One example is the handling of buttons to switch a Boolean indicator on or off (on attendance registers, access indicators, etc.).

For example, I have a field called “IsDisabled” in the People table.  It’s on (i.e. set to 1) if the person is disabled, off (0) if not.  (In the old days, this was a “yes/no” field, but this caused me all sorts of frustrations and limitations – Boolean is the way to go.)  To amend and display this field, this is what I do:

  • On the layout, rather than the field itself, I have a small button.  It’s 15×15 on the desktop version of the layout, 34×34 on the iOS versions, with nicely rounded corners, consistent with the excellent River (or River Touch) theme that I’m using.

Image

  • The button just toggles the field, e.g. Set Field [PPL::IsDisabled; not PPL::IsDisabled]
    (Note that the “not” has the effect of reversing the current setting – 1 becomes 0, 0 becomes 1.)
  • The button is filled with a suitable colour – I use a solid green, to indicate “on”, with conditional formatting to show “no fill” if the field is not set.  So the formatting is:

cond_format_ind copy

Buttons in FM12 have several states, and these can be used to fine-tune the user experience.  I choose, for example, to use the solid green colour for the “Hover” state, as well as the “Normal” state – i.e. if it’s currently “off”, it will show green when the user hovers over it, to show what will happen if s/he selects it, but if it’s “on”, it will continue to show green on hover.  When making this decision I was led by Google Apps, and it does seems the most “intuitive” way to present it.

What I like about this technique is that it’s really simple, and uses FM’s own stuff.  Others may choose to use a graphic indicator (an arrowhead maybe?), and other non-FM tweaks, as I have done in the past, but after many hours spent fiddling with “home made” interface elements which sometimes end up looking wrong (or just different) on different screens etc., I’ve resolved to use native FM features in the re-write wherever possible.

Advertisements

15 Comments on “On/Off (Boolean) Fields”

  1. Nicholas Graham says:

    I agree. The built-in layout features of FM12 are much better than previous versions – and booleans are the way to go whenever possible. Much easier to handle and understand in the long-run.

  2. Tomas says:

    Great example of new layout styles. I am curious about searching the field. Is it possible without second field?

    • Dave says:

      Hi Tomas. Not sure that I’ve understood the question. To search for records where the indicator is set, just set the field to 1 in Find mode – no need for a second field.
      Dave.

  3. John H says:

    While there is no doubt this has advantages over a yes/no system, it can be simplified further using FM’s built-in features (and even works with older versions of FM, as I started using this technique on FM Pro 11).

    1. The isDisabled field must be of type Number.
    2. Create a new value list called True. The only content of this list is the number 1.
    3. In the Inspector, set the isDisabled field to display as a Checkbox (which will automatically be formatted using that layout’s theme).
    4. Choose True from the available value lists.
    5. Resize the field to hide the 1. For a field using 12-point Verdana, 16×16 is a good size.

    That’s it. No scripts, no conditional formatting. Just a simple on/off toggle.

    Now, if you want a solid fill like a radio button, this trick won’t work (although a radio button can be cleared by hitting Backspace, but most users won’t figure that out on their own…)

    • Dave says:

      John – that’s really neat, thanks for sharing. My only reservation is that, being based on a checkbox, it uses “X” to indicate “Yes”. My users have often commented that “X” suggests “No” to them, and I’ve often wished that FM would enable us to specify the character used in checkboxes – a tick (check mark?) would be much more intuitive.

      But I really like the simplicity of your technique.

      Dave.

      • Tomas says:

        Other option is to format number field as a special character. Non-zero and zero values can be displayed differently in inspector.

  4. Hey, I liked your example, but now it is time for FileMaker 13. Did it change something in this matter?
    Is it possible to make a button change color like 0=green and 1=red? The use of the checkbox is not an option in my example. Think of it as a status button to indicate if a parking spot has a car or not.

    • Dave says:

      Hello Marco. The best way to achieve what you need is probably to have the button filled with one colour (i.e. the “off” colour – red?) at the start, and then use conditional formatting to make it green when “on”, as described above. That said, I’m tending to use the method described by John H, because it’s so much simpler.

      Dave.

  5. This solution is bloody brilliant! Thanks so much for this!

  6. I’ve got a question though. How do you make the green hover state apply to the false option as well? For me the conditional format seems to override all states?

    • Dave says:

      Hello Per – thanks for the feedback. I think the hover thing must have changed in FM13. In FM12, I believe the hover state that you specify overrides the conditional formatting (although I can’t test that at the moment). I’m afraid I have no suggestion as to how to get around this in 13. That said, I would encourage you to consider the “single value value list” suggestion described by John H here in the comments – it’s even simpler.
      Dave.

      • I tried that technique. But one thing irks me. I want the boolean field to be either 0 or 1. In this option it is either null or 1. I have it set up with auto-enter 0 for the boolean field. So the way checkboxes work in FM13 is that it only appends the 1 to that 0 when checked. It can’t actually be a toggle.

        But maybe holding on to the 0 is futile? The only place I need it is when a user searches. How does the single checkbox-method work with searching? Does it just look for the checked value in the value list for that field?

  7. And another question (sorry for the spam). Do you have a good solution for the search problem? When a user enters find mode, the boolean field is not set to anything yet (since all fields are blank as a starting point). The user has to check and uncheck our button to search for records with false in that field.

    This is not that intuitive. Do you have a solution for this?

    • Dave says:

      Per – depending on how you’re doing the Find, you could use the “OnModeEnter” script trigger, to set these boolean field(s) to false.
      Dave.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s