Assign the adress mail of user when creating his profil

1
+1
-1

Hello,

i want to create in the same time the mail adresse of user thatway : After that the user complete de form i take his mail adresse and i create it exacly as i create a new profil with Login + PW as follow :

final UserCreator user = new UserCreator (field_u_login3, field_u_pw3);
user.setFirstName(field_f_name3).setLastName(field_p_name3);
apiAccessor.getIdentityAPI().createUser(user);

But i dont know what code to write to fill the mail adresse as i did with Login and PassWord

1 answer

1
0
-1

Hello Rahmi,

There is an ContactDataCreator which accepts an email address. It can be used with the UserCreator, either with the setPersonalContactData(...) method or with the setProfessionalContactData(...) method.

The javadoc is there : https://documentation.bonitasoft.com/javadoc/api/7.8/index.html

Your code would become:

final UserCreator userCreator = new UserCreator(field_u_login3, field_u_pw3);
userCreator.setFirstName(field_f_name3).setLastName(field_p_name3);
        
final ContactDataCreator contactDataCreator = new ContactDataCreator();
contactDataCreator.setEmail(field_e_address3);
// userCreator.setProfessionalContactData(contactDataCreator)
userCreator.setPersonalContactData(contactDataCreator);
        
try {
    apiAccessor.getIdentityAPI().createUser(userCreator);
} catch (CreationException e) {
    logger.log(Level.SEVERE, "User Creation failed: " + e.getMessage(), e);
}

IMPORTANT

the variables' names, with field_ prefix, might suggest that these lines of code are executed from within old V6 form. They are deprecated since 7.0 and removed from the product since the 7.8. We recommend to switch to the new V7 forms plus REST API extensions instead.

Regards,

Jerome

Notifications