Create a new User and Portal Profile from system task/script

1
0
-1

Hello,

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:

import org.bonitasoft.engine.api.APIClient
import org.bonitasoft.engine.api.IdentityAPI
import org.bonitasoft.engine.identity.User
import org.bonitasoft.engine.profile.Profile
import org.bonitasoft.engine.profile.ProfileMemberCreator
org.bonitasoft.engine.api.APIClient apiClient = new APIClient()
apiClient.login("install", "install")
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() )
orgProfileAPI.createProfileMember(profileMemberCreator)

I have also linked the .bos file. Any help would be greatly appreciated.

https://drive.google.com/open?id=1trIM4tF5zGFYh_bQbIiDCTR1SQdKdCHw

No answers yet.
Notifications