You need to sign in to do that
Don't have an account?
VictorBV
Error while creating User for Customer Portal
Hi,
I am trying to create a user for a customer portal.
In order to do so I use next code:
Profile portalProfile = [select id, Name from profile where name='Customer Portal Manager Custom']; UserRole role = [select id, Name from UserRole where name = :companyName + ' Cliente Usuario']; User portalUser = new User(alias = contact.UserCode__c, email = email, mailencodingkey = 'UTF-8', lastname = contact.LastName, languagelocalekey= 'es', localesidkey= 'es', profileid = portalProfile.Id, timezonesidkey= 'Europe/Paris', username = userName, userRoleId = role.Id);
Role has been previously created.
I got next error:
INVALID_CROSS_REFERENCE_KEY, invalid cross reference id
And I think it is beacuse of profile. User is not identified as Portal User so I can not assign a Portal Profile.
But I dont know how to overcome that issue.
Someone knows how to do it?
I have checked
http://blog.sforce.com/sforce/2009/04/provisioning-customer-portal-users-with-apex.html
But field User.ContactId does not exist any longer....
Thanks in advance
Hi,
Try including one more parameter while inserting user."ContactId = contact.Id" where contact.Id is the Id of the contact which is to be created as the Customer Portal User.
Hope this helps.
Thanks