1

I am creating gmail single sign on in salesforce...i have created class to implement RegistrationHandler Interface but when i try to login with new user it gives an error

Error :Missing Required Field username ,email,NickName....

please suggest a solution ..................................................... My class Is given below.............

    global class GoogleOpenIDConnect implements Auth.RegistrationHandler{

      global User createUser(Id portalId, Auth.UserData data){
        User u = new User();
        System.debug(data);
        Profile p = [SELECT Id FROM profile WHERE name='Standard User'];
        u.username = data.username;
        u.email=data.email;
        u.lastName = data.lastName;
        u.firstName = data.firstName;
        u.timeZoneSidKey = 'America/Los_Angeles';
         u.localesidkey = 'en_US';
        u.emailEncodingKey = 'ISO-8859-1';
        u.languagelocalekey = 'en_US';


        String alias = data.firstName + data.lastName;
        if(alias.length() > 8) {
           alias = alias.substring(0, 8);
        }
        u.alias = alias;
        u.profileId = p.Id;
        return u;
  }

  global void updateUser(Id userId, Id portalId, Auth.UserData data){
    User u = new User(id=userId);
      System.debug(data);
    u.email = data.email;
    u.lastName = data.lastName;
    u.firstName = data.firstName;
    update(u);
  }
}
  • What method or line is giving that error ? Either way the error is quite clear, you have to make sure that all required fields are populated with a value when inserting data to the database. – Samuel De Rycke Aug 2 '14 at 23:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.