function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ralfo A. NunesRalfo A. Nunes 

Using Apex: Custom Picklist field saved different values depending on User Language

When trying to set a value in picklist field using APEX for a custom object, we need to guarantee the same value disregarding the user current language when the record is saved.

Current code:
Custom_Object__c ojb = new Custom_Object__c();
ojb.Status__c = 'Liberado';

Org is working with 2 languages (Portuguese and English), where picklists are translated. Portuguese is default.

Issue: If we run as a user in English, the record is saved with the value 'Released' instead of 'Liberado'. That is, the value saved in the record is different depending on the user language, what is a big issue for the system logic.

Question: is this the standard behavior? How can we guarantee the same value using the APEX?
Anil kumar GorantalaAnil kumar Gorantala
refer this document : https://help.salesforce.com/apex/HTViewSolution?id=000005218&language=en_US maybe user has his own language settings
Ralfo A. NunesRalfo A. Nunes
The problem is when User changes the own laguange, in database Salesforce sets different value from Apex Code (ojb.Status__c = 'Liberado';).
E.g:
In translation Workbench: Picklist has value: Liberado  (for Portuguese) and Released (for English).

If user is Logged in Portuguese, in Database is saved value as "Liberado"
If user is Logged in English, in Database is saved value as "Released"

Because that my logic program stop to work as it designed. I have a logic on this value, e.g: If (ojb.Status__c == 'Liberado') { Part of my program}