Is it possible to configure a process so that next input dialog opens for the same user immediately after the previous dialog was completed? (also called form chaining or pageflow).
I have valid use case as I know who will be the next assigne, which was same one that claimed the process?
It would be nice if this could be accomplished by using default flowable genrated forms.
Hi,
this will not work for Input Dialog forms out of the box. You can try to implement it using CUBA screen process forms.
In the process form, after you complete the current task you may analyze if the new user task appeared for the current user and if so then show the next process form.
You process form may look like this:
@UiController("sample_ChainProcessForm")
@UiDescriptor("chain-process-form.xml")
@ProcessForm
public class ChainProcessForm extends Screen {
@Inject
protected ProcessFormContext processFormContext;
@Inject
protected BprocTaskService bprocTaskService;
@Inject
private UserSession userSession;
@Inject
private ProcessFormScreens processFormScreens;
@Inject
private Label<String> taskNameLabel;
@Subscribe
public void onBeforeShow(BeforeShowEvent event) {
TaskData taskData = processFormContext.getTaskData();
taskNameLabel.setValue(taskData.getName());
}
@Subscribe("completeBtn")
public void onCompleteBtnClick(Button.ClickEvent event) {
//complete the current user task
processFormContext.taskCompletion().complete();
//find user tasks of the same process instance that are assigned to the current user
TaskData taskData = processFormContext.getTaskData();
List<TaskData> nextTasks = bprocTaskService.createTaskDataQuery()
.processInstanceId(taskData.getProcessInstanceId())
.taskAssignee(userSession.getCurrentOrSubstitutedUser())
.list();
//close the current form
closeWithDefaultAction();
//if new tasks were assigned to the current user, then we create a process form screen and show it
if (!nextTasks.isEmpty()) {
TaskData nextTaskData = nextTasks.get(0);
Screen nextTaskProcessForm = processFormScreens.createTaskProcessForm(nextTaskData, getWindow().getFrameOwner());
nextTaskProcessForm.show();
}
}
}