Skip to main content
edited tags
Link
Adrian Larson
  • 151.3k
  • 38
  • 247
  • 431
Tweeted twitter.com/StackSalesforce/status/1195174941278257153
Source Link
Oleh Berehovskyi
  • 7.8k
  • 7
  • 30
  • 54

Why does the LIKE SOQL operator implicitly translate picklist values?

Assume, I've got a standard picklist field Rating on Account with values Hot, Cold. Using enabled Translation Workbench I've translated these values into German. When the language of a user is set to English, and the user performs a SOQL query

SELECT Id, Rating FROM Account WHERE Rating LIKE 'Cold'

it returns N records. But if we change the language of the user to German, the same SOQL query returns 0 records. However, when it changes to

SELECT Id, Rating FROM Account WHERE Rating LIKE 'Kalt'

it returns N records as well as for the very first scenario. At the same time, the returned values of the Rating field remain untranslated ('Cold'). This means that the LIKE operator implicitly translates the values of picklists before comparison. I've tested IN, NOT IN, = SOQL Comparison Operators and they don't behave like LIKE, they perform a comparison based on picklist value API Name not Label. There is no such information about it in Salesforce Docs. So finally my question is:

Why does the LIKE SOQL operator implicitly translate picklist values before comparison and how to perform a comparison based on picklist value API Names using the LIKE operator?