Advertisement
kpammi

CustomCommunitiesSelfRegController

Aug 30th, 2016
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.13 KB | None | 0 0
  1. //This is the server-side controller which is called once the user submits the form on the community page.
  2. //It takes the form data and parses it to an Object, which is then used to create the user.
  3. public class CustomCommunitiesSelfRegController {
  4.  
  5.     //get a user to manipulate on the form
  6.     @AuraEnabled
  7.     public static User getUser() {
  8.  
  9.         User u = new User();
  10.         return u;
  11.  
  12.     }
  13.  
  14.     @AuraEnabled
  15.     public static String createNewUser(String userData) {  
  16.         system.debug('User Data'+userData);
  17.         if(userData!=null){
  18.             JSONParser parser = JSON.createParser(userData);
  19.             SelfRegistrationTempObj o = (SelfRegistrationTempObj)parser.readValueAs(SelfRegistrationTempObj.class);
  20.             system.debug('SelfRegistrationTempObj'+o);
  21.             User u = new User();
  22.             u.FirstName = o.FirstName;
  23.             u.LastName = o.LastName;
  24.             u.Email = o.Email;
  25.             u.CompanyName = o.CompanyName;
  26.             u.Title = o.Title;
  27.             return createNewUserSelfRegistration(u);            
  28.         }
  29.         return 'Please populate user data.';   
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement