System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [LastName, Email, Alias, TimeZoneSidKey, LocaleSidKey, EmailEncodingKey, ProfileId, LanguageLocaleKey]: [LastName, Email, Alias, TimeZoneSidKey, LocaleSidKey, EmailEncodingKey, ProfileId, LanguageLocaleKey]
what values shoul be given to
TimeZoneSidKey, LocaleSidKey, EmailEncodingKey, ProfileId, LanguageLocaleKey
Apart from this can anyone suggest code to use the user details of existing user through apex code?
답변 2개
One way is to use an existing user while testing. see below: User u1 = [SELECT Id FROM User WHERE Alias='auser'];
//Run As U1
System.RunAs(u1){
// your code here..
}
Other way is like you are trying to do:
Try this:localesidkey='en_US'
emailencodingkey='UTF-8'
languagelocalekey='en_US'
localesidkey='en_US'
Get profile Id by:
Profile p = [select id from profile where name='Standard User'];
and then use ProfileId = p.IdHope this helps!!!