Monday 8 December 2014

Salesforce Community (Site) Methods

Some time we need to override Salesforce community login page in that case we need to to write custom code to create user , login, forget password etc. For that we can use the below salesforce predefined function :-
Login Function :-

If we need to login in salesforce community then we can use below function :-
Site.login(username, password, null);

Create User :- 

We can create two type for user for salesforce community :-
1) Portal user
2) Person Account Portal User

Please use below code to create simple portal user :-

String accountId = PORTAL_ACCOUNT_ID;
String userId = Site.createPortalUser(u, accountId, password);

Please use below code to create Person Account Portal user :-

String ownerId = OWNER_ID;
String userId = Site.createPersonAccountPortalUser(u, ownerId, password);

Change Password :-
public static System.PageReference changePassword(String newpassword, String verifynewpassword, String opt_oldpassword);

Forget Password :-
public static Boolean forgotPassword(String username);

Related link for all Site Method :-

Amit Chaudhary
Email :-

No comments:

Post a Comment