You need to sign in to do that
Don't have an account?
Urgent Help-Creating PartnerPortal User in Test Class having issue with IsPortalEnabled
Hi I need to write test class for partner portal users. The problem is i am not able to create partner portal user in test class
due the error IsportalEnabled is not writable.
User approverUser = new User(ProfileId = prof.id,LastName = 'Test', FirstName = 'Test', Username = 'testing456@test.com', Alias='test', CommunityNickname='test Approve', Email='test@email.com',TimeZoneSidKey='America/Chicago',EmailEncodingKey='ISO-8859-1', LanguageLocaleKey='en_US', LocaleSidKey='en_US',IsActive=false,IsPortalEnabled = true,Email_Address__c='test@email.com',EmployeeNumber='6534866',Legacy_Employee_Ref__c='487547');
Insert approverUser ;
I uderstand that this field is not writable.Can you please suggest how i can do the test class for this scnario.
Thanks and Regards,
Venkatesh
You may try this,,,
Profile profile = [ select Id from Profile where Name=:profileName];
Contact contact = new Contact(AccountId = accountId, LastName = lastName);
insert contact;
User user = new User(ContactId = contact.Id,
Username = 'username',
Email = 'username',
LastName = 'lastName',
Alias = 'alias',
ProfileID = profile.Id,
PortalRole = 'Manager',
LocaleSidKey = 'en_US',
LanguageLocaleKey = 'en_US',
TimeZoneSidKey = 'America/Los_Angeles',
EmailEncodingKey='UTF-8'
);
insert user;
user.IsPortalEnabled = true;
update user;
return user;
}