In our application we are adding and removing roles programatically, because we need different users to see certain tasks, depending on where in the workflow they are, mainly one user getting a task to review the work another user has done. We want everyone, except the user, who is getting reviewed, to see that review-task. We are doing that by programatically creating a new role that everyone but the reviewed user gets.
Then after the review-task is finished, we are removing this role from everyone who has it and delete it.
(we delete it the same way that was suggested in https://community.axonivy.com/d/39-remove-created-irole-with-public-api)
This has worked flawlessly since Axon.Ivy 6. However with Axon.Ivy 8.0.11 we are experiencing race-conditions in the whole role-handling.
The error is always the same:
Caused by: ch.ivyteam.ivy.scripting.exceptions.runtime.IvyScriptRuntimeException: IvyScript Runtime Exception in
Instruction:
ch.ivy.addon.portalkit.ivydata.service.impl.SecurityService.newInstance().findRoles(in.application)
Block:
ch.ivyteam.wf.processes.SecurityServiceData out;
out = in;
ch.ivy.addon.portalkit.ivydata.dto.IvySecurityResultDTO dto = ch.ivy.addon.portalkit.ivydata.service.impl.SecurityService.newInstance().findRoles(in.application);
out.roles = dto.roles;
out.errors = dto.errors;
...
Caused by: ch.ivyteam.ivy.scripting.exceptions.invocation.IvyScriptMethodInvocationException: Error calling method findRoles(ch.ivyteam.ivy.application.IApplication) on an object of class ch.ivy.addon.portalkit.ivydata.service.impl.SecurityService.
...
Caused by: ch.ivyteam.ivy.persistence.PersistentObjectDeletedException: Persistent object has been deleted [class=class ch.ivyteam.ivy.security.internal.data.RoleData, id=9]
...
The scale of the problem is such, that even leaving the application, going back to the engine-site and entering the Portal again, via "Application Home", produces this exact same error. Clearing the browser-cache gets rid of it.
Our guess is that somehow something about the roles is cached and not kept up-to-date. Could you help us out here?