3

Consider two fields with the following types:

  1. checkbox/boolean
  2. picklist with "yes" and "no" as valid values along with validation that forces one of the two values to be picked, effectively making it a boolean.

Is there ever a benefit to using the second field type have over the first? Is there any situation where a yes/no picklist makes more sense than a boolean?

4
  • This was closed by the community because answers would be entirely opinion based. It definitely depends on the business context, and you'd be better off asking on a site that supports discussion such as the developer boards.
    – Matt Lacey
    Aug 28, 2014 at 12:00
  • Eh, ok. I didn't ask "what do you think," canvass for opinions, etc. and kept it objective but okay.
    – user6861
    Aug 28, 2014 at 12:28
  • Wasn't my decision, I was just adding feedback because the system flags closed posts to moderators :) I just tweaked the text a little, and I'm going to re-open it.
    – Matt Lacey
    Aug 28, 2014 at 12:41
  • I think part of the problem was confusion about the precondition on the picklist: it cannot be null. I know what the difference is, I was curious if there is a technical reason why it might offer something the checkbox would not. I suspect the answer is "no" but I wanted to run it by other SF experts to see if the platform offered something in that regard of which I am unaware.
    – user6861
    Aug 28, 2014 at 21:07

2 Answers 2

5

Checkbox

Advantages

  • Will never be indeterminate. This is useful for coding, mostly.
  • Can be represented in different ways. You can use 0, 1, true, and false. This reduces import errors, and simplifies report criteria.
  • Is a true Boolean. This means formulas don't need ISPICKVAL to work, so they are simpler to read. This is also true in code.
  • Requires only one click to toggle. Fewer clicks improves UX.

Disadvantages

  • Cannot be indeterminate. This is a drawback when trying to represent data that may be unknown.
  • Can't be changed to other data types later without data loss.

Picklist

Advantages

  • Can be easier to read. A checkbox always shows a graphic image in reports instead of text. Unlike checkboxes, you'll get a friendly yes or no instead of an image.
  • Can represent unknown values. Data isn't always initially available, so having an indeterminate value can be useful.
  • Can present either option on top.

Disadvantages

  • Requires translation for every language your org uses. Very cumbersome for multilingual apps on the app exchange.
  • Complicates formulas with ISPICKVAL and so on. Makes Apex Code slightly more verbose. Also lends itself to coding errors.
  • UX suffers. At least two clicks and an extra mouse move per selection.

Summary

In general, use a checkbox when possible for a better UX and easier maintenance. However, do use a picklist when you expect answers to be unknown from time to time.

Examples

Is driver insured? [yes/no] Error Present [checkbox] Over 18? [yes/no] Requires Approval [checkbox]

The examples go on and on. In general, if you need to present an option that requires research, and might not be immediately known, use a picklist.

If an answer is always known (or, at least, should always be known), use a checkbox.

2

This really depends on your business requirement. So ideally you should ask this question to your business stakeholders.

One possible advantage of a picklist is that you can have an unanswered option. Users can choose not to answer this question ( provided it is not mandatory ). So the value will remain null. With boolean it is just true or false. If user does not answer, the boolean remains false.

Picklist may also allow you to add additional options like "Maybe" or "Do not want to answer". With boolean this is not possible.

1
  • The precondition is "yes" and "no" are the only valid values as stated in my question. I will mention that this is a loaded question: I already know my answer, but am curious if there is some framework-level difference that is useful.
    – user6861
    Aug 28, 2014 at 3:36

You must log in to answer this question.