SF Trigger to create Portal user upon creating contact.
Requirement Specification:
We need to create a user record when a contact record is created:
-Timezone: We need to go and read from the Account's timezone field.
-Current values for timezone are
Pacific Mountain Central Eastern Alaskan Hawaiian New Foundland Australia/Sydney
Any unknown value should be set to "America/New_York"
Record must have the following fields populated
alias = 'contact.lastName',
email = 'contact.email',
emailencodingkey = 'UTF-8',
firstname = 'contact.firstName',
lastname = 'contact.lastname',
languagelocalekey = 'en_US',
localesidkey = 'en_US',
contactId = 'contact.Id',
timezonesidkey = 'America/New_York' (this value changes)
username = 'contact.email',
CommunityNickname ='contact.lastName'
ProfileId = '00e0Y000001M7qf' (nb; not recommended)
IsActive = true
Also we need to test whether the user get's the welcome email.
-Test class is required as well.
Deliverables
The Trigger
Test Class: 100% code coverage