1

When creating new view for listing objects within standard Salesforce I can set the filter criteria. It is possible of course to filter by some picklist value. The value can be entered manually or with lookup-like chooser. Then, when I manually enter some value that is not predefined, I get the Error: Picklist value does not exist.

But, when I set the same picklist filed with some non-predefined value from APEX, say abc, then I can insert abc as the value in filter section when creating a view and get no errors. However it is still not present in the chooser.

I'm sure it's not a bug but I'm wondering what is the reason of such behavior. I found it a little bit confusing.

1 Answer 1

1

Fields of type picklist are designed to coerce user input to allowed values; Picklists also make report filter creation more reliable. However, as you noted Apex/API/Data Loader can insert any value into a type Picklist or Multi-Select Picklist field.

I can imagine a few reasons for this --

  • data that starts as type Text and then changed to picklist - without having to force a data migration in advance (or worse, forcing apex code to change in advance)
  • wanting to avoid having api clients fail when they insert values that don't agree with the then-current picklist choices

Once a value for a given record that is not in the picklist is inserted, the picklist for that record includes the new, non-compliant value. This makes sense as that is the value saved in the record

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .