Hi,
I want to assign task to users of the same role which i assigned during model design.
But here the problem is i am not able to get which role i have assigned to the user task.
I need this before starting the process or creating process task object.
I tried to get process role of user task by following code.
String actProcessDefinitionId = "";
String actTaskDefinitionKey = "";
ProcDefinition procDefinition = findProcDefinition("caseApproval");
actProcessDefinitionId = procDefinition.getActId();
Map<String, List<ExtensionElement>> taskExtensionElements = new HashMap<>();
BpmnModel bpmnModel = repositoryService.getBpmnModel(actProcessDefinitionId);
FlowElement flowElement = bpmnModel.getFlowElement(actTaskDefinitionKey);
taskExtensionElements = flowElement.getExtensionElements();
List<ExtensionElement> procRoleElements = taskExtensionElements.get("procRole");
if (!procRoleElements.isEmpty()) {
ExtensionElement procRoleElement = procRoleElements.get(0);
return procRoleElement.getElementText();
}
protected ProcDefinition findProcDefinition(String processCode) {
LoadContext ctx = LoadContext.create(ProcDefinition.class);
ctx.setQueryString("select pd from bpm$ProcDefinition pd where pd.code = :code")
.setParameter("code", processCode);
return (ProcDefinition) dataManager.load(ctx);
}
If i hard coded some value to actTaskDefinitionKey lets say actTaskDefinitionKey = “sid-2BEEB4B7-181C-4902-8A22-225D7BC81CB7” then i am able to get process role.
But how i will get that value dynamically.
Please help or suggest me how to solve it or give any idea to get process role.
Your help will be greatly appreciated.
Regards,
Subrat