SOQL LIKE Comparison Operator using Translation Workbench Picklist Values
Last updated 2016-07-28 ·Reference W-2234057 ·Reported By 2 users
When querying with SOQL, if the where clause has a comparison with a Picklist Value that is translated with the Translation Workbench, the LIKE operator will not work with the Picklist defined values for the field.
The LIKE operator is using the translated value set in the Translation Workbench for the end-users set user language.
1) Create a picklist/choose a picklist to translate
2) Go to the Translation Workbench: Setup > Translation Workbench > Translate
3) Choose the language to translate. Set the Setup Component as Picklist Value and choose the object of the picklist
4) Put in some translations for the desired picklist
5) Perform a SOQL query with the binding value in the language the value is stored in the picklist:
SELECT Picklist__c FROM Object__c WHERE Picklist__c LIKE '%Value%'
# records returned
6) Change your user language to the Translation language you set in step 3 and query again with query above.
0 records returned
7) Change the binding value into the language you have set:
e.g. (French): SELECT Picklist__c FROM Object__c WHERE Picklist__c LIKE '%Valeur%'
# records returned
You can continue to use the = or IN operators which will return the DB defined values within the picklist definition.
SELECT Picklist__c FROM Object__c WHERE Picklist__c = 'Value'
SELECT Picklist__c FROM Object__c WHERE Picklist__c IN ('Value', 'Value 2')
To return the values in the end-user's language you must use toLabel():
"A client application can have results from a query returned that are translated into the user’s language, using toLabel()"
Is it Fixed?
Any unreleased services, features, statuses, or dates referenced in this or other public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make their purchase decisions based upon features that are currently available.