0

I have multi-language environment and I am having trouble regarding the translation of Subject picklist values. It looks like translation of subject field is provided only when inserting task via user interface. After task inserted it is not possible to retrieve translated value although picklist values are translated via translation workbench. Tasks created via Apex also do not follow translation rules for subject field.

Can anyone able to find a workaround for this issue?

Translation Workbench

translated status and subject field

  • Added screenshots and I don't know why it gets minus vote without a comment. Seems like a legit bug to me. – oozkan Apr 27 '18 at 13:49
2

Subject is something called a Combobox, which is really just a fancy way of saying it's a text field with a set of predefined options you can select from. Since it's really a text box, no translation of the value is possible after selection, because the user could modify it to something that doesn't have a translation. For Apex Code, you should be able to iterate through the getPicklistValues() for the field's describe, which would give you the native language value and the translated language value, which you could then use to deduce if there's a valid translation value.

Map<String, String> translationMap = new Map<String, String>();
for(PicklistEntry entry: SObjectType.Task.fields.Subject.getPicklistValues()) {
  translationMap.put(entry.getLabel(), entry.getValue());
}
// Hypothetical use case
for(Task record: Trigger.new) {
  record.English_Subject__c = translationMap.get(record.Subject);
}
| improve this answer | |
  • Thanks @sfdcfox. Then I need to override task page with my own Visualforce page, apparently there is no way to do it in a standard way. I still find it a bit odd to automatically translate subject label to French but not the value although it exist in translate database. Just curiosity, do you have an idea why it is combobox instead of a standard picklist? – oozkan Apr 27 '18 at 14:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.