You need to sign in to do that
Don't have an account?
Nakul Mudgal 8
Enable customer community user using apex
We have person accounts in our org. to whom we need to give access to our customer community at various stages of an opportunity.
Is there a way we can programmatically enable our person accounts as customer users using apex ?
We have Customer Community Login licenses available in our org
Is there a way we can programmatically enable our person accounts as customer users using apex ?
We have Customer Community Login licenses available in our org
You can create Potal user by
If you are creating the customer portal user through internally then you can below sample code to create a customer portal user.
--------------------- Customer Portal User created internally-----------------
Or you can also see this link http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_sites.htm
IF it helps you than please mark it as a solution and ENJOY APEX (http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_sites.htm)
We have to write trigger on opporutnity for your requirments. But i have a quetion here :
There may be multiple contacts associtated with opportunity's account. If opportunity stage is changed do you want to deactivae user access for all the contacts which is related to that account ?
We are not looking to give access to any contacts to our community. We have person accounts attached to our opportunities which need to be enabled as customer users.
And yes we will need the logic to deactivate them as well.
@Ashlekh Gera-
Thanks a lot for the sample code... will this work for Person accounts as well ... i think i'll have to query the personcontactid for the contact.
If i am not wrong whenever we creat a customer community user have to create a user(Record of user object). On that user object record we have a lookup of contact , which is going to be a community user. profile for thant user profile will be community portal or community portal +.
The scenario for which i am talking till now is the case when we make a contact as a portal user or customer user.
In this scinario code can be like this (not tested)