Hi, as part of an authorization process using BPM addon,
I need to get the comment entered during the taskoutcome input dialog.
In the setAfterCompleteTaskListener the procActionsFragment.getProcInstance().getProcTasks()
return Null because the task is not committed yet.
Because I get this error :
How can interact with current active ProcTasks in then setAfterCompleteTaskListener lambda listener ?
thank you for your answer,
In my use case, if I try to use this (your) code with the update of the current Entity:
ProcInstance procInstance = procActionsFragment.getProcInstance();
List procTasks = dataManager.load(ProcTask.class)
.query(“select t from bpm$ProcTask t where t.procInstance = :procInstance”)
.parameter(“procInstance”, procInstance)
.view(View.LOCAL)
.list();
for (ProcTask procTask : procTasks) { getEditedEntity().setAttribute(getEditedEntity().getAttribute().join(" - ", procTask.getComment()));
log.info(“ProcTask name: {}, comment: {}”, procTask.getName(), procTask.getComment());
}
I get the following error:
Exception Description: The object [com.company.workflow.entity.MyEntity-7debd925-cfb7-c5a0-8c63-688222f7469f [detached]] cannot be merged because it has changed or been deleted since it was last read.
because in setAfterCompleteTaskListener the task is not committed yet…
But I tried solved this issue in the bacht-mode in the following way:
public ProcInstance loadProcInstanceById(UUID id) {
LoadContext<ProcInstance > lc = LoadContext.create(ProcInstance.class);
LoadContext.Query query =
LoadContext.createQuery("select e from bpm$ProcInstance e where e.entity.entityId = :id")
.setParameter("id", id) ;
lc.setQuery(query);
return (ProcInstance) dataManager.loadList(lc).get(0);
}
public ProcTask loadProcTaskById(UUID id) {
LoadContext<ProcTask > lc = LoadContext.create(ProcTask.class);
LoadContext.Query query =
LoadContext.createQuery("select e from bpm$ProcTask e where e.procInstance.id = :id")
.setParameter("id", id) ;
lc.setQuery(query);
return (ProcTask) dataManager.loadList(lc).get(0);
}