while inserting user object data in Test Class

System.DmlException: Insert failed. First exception on row 0; first error: INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, Locale: bad value for restricted picklist field: English(Ireland,Euro): [LocaleSidKey]

how to insert localesidkey and Locale Value for user using apex class

  • Can you post your code where you set the User object. Also try English(Ireland) for Locale.
    – highfive
    Apr 26, 2016 at 6:57

1 Answer 1


Here you have an example of how create a user in apex


 Profile p = [SELECT Id FROM Profile WHERE Name='Standard User']; 
        User u = new User(Alias = 'standt', Email='[email protected]', 
            EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US', 
            LocaleSidKey='en_US', ProfileId = p.Id, 
            TimeZoneSidKey='America/Los_Angeles', UserName='[email protected]');

List of Locales and corresponding codes (LocaleSidKey) with its formats for Date, Names and Numbers can be found in Supported Locales.

  • 1
    Thx @vigneshwaran-g for add the list of supported locales.
    – Torsen
    Apr 26, 2016 at 7:08

You must log in to answer this question.