3

Does anyone know practical application or a sample code for DMLOptions --localeoptions

Documentation says:

localeOptions Property
The localeOptions property specifies the language of any labels that are returned by Apex. The value must be a valid user locale (language and country), such as de_DE or en_GB. The value is a String, 2-5 characters long. The first two characters are always an ISO language code, for example 'fr' or 'en.' If the value is further qualified by a country, then the string also has an underscore (_) and another ISO country code, for example 'US' or 'UK.' For example, the string for the United States is 'en_US', and the string for French Canadian is 'fr_CA.'

But i couldn't make it work with sample code below,I expected to see record in database in German below..May be i got the purpose of this all together wrong.please guide

Account a = new account(name=System.Label.label1);
database.dmloptions d = new database.dmloptions();
d.localeoptions ='de_DE';

database.insert(a,d);
2

I think your interpretation is not correct. It just change the labels you see on page. It will not do any translation of data.

More accurate example would be like this:

Notice that the labels are translated.

public void localeOptionsExample() {
try {
    connection.setLocaleOptions("en_US");
    connection.describeSObject("Account");

    connection.setLocaleOptions("en_DE");
    connection.describeSObject("Account");

  } catch (ConnectionException ce) {
    ce.printStackTrace();
 }
}

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_header_localeheader.htm

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.