Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Account a = [select name from Account where Id='0010Q00000DO8b7QAD'];
- Contact c = New Contact(LastName = 'Test', AccountID = a.id);
- insert c;
- Profile p = [SELECT Id FROM Profile WHERE Name = 'Customer Community user' LIMIT 1];
- user u = New User(
- UserName = 'test_' + math.random() + '@test.com',
- FirstName = 'Test-First',
- LastName = 'Test-Last',
- Alias = 'test',
- email = 'test' + math.random() + '@test.com',
- CommunityNickName = string.valueOf(math.random()).substring(0,6),
- ProfileID = p.id,
- TimeZoneSidKey = 'America/New_York',
- LocaleSidKey = 'en_US',
- EmailEncodingKey = 'UTF-8',
- LanguageLocaleKey = 'en_US',
- ContactID = c.Id
- );
- system.debug('User = ' + u.Id);
- insert u;
- return u;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement