Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. Account a = [select name from Account where Id='0010Q00000DO8b7QAD'];
  2.  
  3. Contact c = New Contact(LastName = 'Test', AccountID = a.id);
  4. insert c;
  5.  
  6. Profile p = [SELECT Id FROM Profile WHERE Name = 'Customer Community user' LIMIT 1];
  7.  
  8. user u = New User(
  9. UserName = 'test_' + math.random() + '@test.com',
  10. FirstName = 'Test-First',
  11. LastName = 'Test-Last',
  12. Alias = 'test',
  13. email = 'test' + math.random() + '@test.com',
  14. CommunityNickName = string.valueOf(math.random()).substring(0,6),
  15. ProfileID = p.id,
  16. TimeZoneSidKey = 'America/New_York',
  17. LocaleSidKey = 'en_US',
  18. EmailEncodingKey = 'UTF-8',
  19. LanguageLocaleKey = 'en_US',
  20. ContactID = c.Id
  21.  
  22. );
  23.  
  24. system.debug('User = ' + u.Id);
  25.  
  26. insert u;
  27.  
  28. return u;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement