Guest User

Untitled

a guest
May 23rd, 2018
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. Id profId = [SELECT Id FROM Profile WHERE Name = 'Community Knowledge User' LIMIT 1].Id;
  2. Account a = new Account(Name = 'Test5');
  3. insert a;
  4. Contact c = new Contact(AccountId = a.Id,
  5. FirstName = 'Morgan',
  6. LastName = 'Ma',
  7. Email = 'testusr5@test.ourwebsite.com',
  8. Title__c = 'Administrator');
  9. insert c;
  10. User u = new User(ContactId = c.Id,
  11. Alias = 'MSstA5',
  12. FirstName = c.FirstName,
  13. LastName = c.LastName,
  14. Email = c.Email,
  15. Username = c.Email,
  16. ProfileId = profId,
  17. EmailEncodingKey = 'ISO-8859-1',
  18. LanguageLocaleKey = 'en_US',
  19. LocaleSidKey = 'en_US',
  20. TimeZoneSidKey = 'America/New_York');
  21. insert u;
  22. System.setPassword(u.Id, 'Welcome1*');
Add Comment
Please, Sign In to add comment