Create a new User and Portal Profile from system task/script
I am attempting to create a new organization user form, after which a new user and portal profile is added. The user form is the instantiation form, and it contains the new user's username. For testing purposes, password is a static string. After the form is submitted, a system task is created that runs a script that generates the new user and the user's portal profile. The user part works fine, but I am unable to create the user's Portal Profile.
Here is the Bonita Engine Log error:
jdbc.JdbcSQLIntegrityConstraintViolationException: Referential integrity constraint violation: "FK_PROFILEMEMBER_PROFILEID: PUBLIC.PROFILEMEMBER FOREIGN KEY(TENANTID, PROFILEID) REFERENCES PUBLIC.PROFILE(TENANTID, ID) (1, 105)"; SQL statement:
insert into profilemember (profileId, userId, groupId, roleId, tenantId, id) values (?, ?, ?, ?, ?, ?) [23506-199]
And the script I am using to generate the new user and Portal Profile:
org.bonitasoft.engine.api.APIClient apiClient = new APIClient()
IdentityAPI identityAPI = apiClient.getIdentityAPI()
User user = identityAPI.createUser(registroTitular.username, "bpm")
org.bonitasoft.engine.api.ProfileAPI orgProfileAPI = apiClient.getProfileAPI()
ProfileMemberCreator profileMemberCreator = new ProfileMemberCreator( user.getId() )
profileMemberCreator.setUserId( user.getId() )
I have also linked the .bos file. Any help would be greatly appreciated.