I have a problem with setting UserMembership on a “Blank” User, created on Anonymous User, with his Form Inputs.
The user and his profile is created, but not his Usermembership on his UserDetails in Portal Bonita.
This is the Groovy code:
UserCreator creator = new UserCreator(tsk2_emailStudent, tsk2_CodeStudent);
creator.setFirstName(tsk2_nameStudent).setLastName(tsk2_StudentLastname);
ContactDataCreator proContactDataCreator = new ContactDataCreator().setFaxNumber(tsk2_codeStudent);
creator.setProfessionalContactData(proContactDataCreator);
final IdentityAPI identityAPI = apiAccessor.getIdentityAPI();
final User user = identityAPI.createUser(creator);
ProfileAPI orgProfileAPI = apiAccessor.getProfileAPI();
SearchOptionsBuilder searchOptionsBuilder = new SearchOptionsBuilder(0,10);
searchOptionsBuilder.filter(ProfileSearchDescriptor.NAME, tsk2_emailStudent);
SearchResult searchResultProfile = orgProfileAPI.searchProfiles(searchOptionsBuilder.done());
if (searchResultProfile.getResult().size()!=1)
{ return; }
Profile profile = searchResultProfile.getResult().get(0);
ProfileMemberCreator profileMemberCreator = new ProfileMemberCreator( profile.getId());
profileMemberCreator.setUserId(creator.getId());
Group stugroup = apiAccessor.identityAPI.getGroupByPath[“plataform”,“Students”];
Role sturole = apiAccessor.identityAPI.getRoleByName(“Group”);
/*
profileMemberCreator.setGroupId(stugroup.getId());
profileMemberCreator.setRoleId(sturole.getId());
*/
//This is using ProfileMemberCreator, setting role.id() group.id().
orgProfileAPI.createProfileMember(profileMemberCreator);
apiAccessor.identityAPI.addUserMembership(tsk1_studentID, stugroup.getId(), sturole.getId());
//using UserMemberShip.
Both them are not working, anyone know how to fix this problem, help me, please.
Regards, Peter Grant