Synchronize data as process variable using syncAvailableFieldsDelegate

In workflow 10.4.0, when using syncAvailableFieldsDelegate to synchronize data from DS I got the outdated data.

I my case, the camunda process has numbers of userTasks, when userTask is completed I need to collect data from document in order to make a next decision.
So right after userTask completed I listen task ‘complete’ event to handle that:

    @EventListener(condition = "#delegateTask.getEventName().equals('complete')")
    public void onTaskComplete(DelegateTask delegateTask) {
        syncAvailableFieldsDelegate.execute(delegateTask.getExecution());
    }

In addition, to update document and complete task - the two RPC operations MODIFY_DOCUMENT & TASK_COMPLETE are put in the same request.

Because these operations are in one transaction, so when syncAvailableFieldsDelegate.execute is triggered the change from MODIFY_DOCUMENT is not committed do database yet, therefore the returned result doesn’t contain expected data.

So in my case, how can I fetch the updated data from DS by using syncAvailableFieldsDelegate?

Moin @nguyen-sharp-drift,

Workflows introduced a new asynchronous mode in 2023.06-ext3. Please try enabling it by configuring the following property in your project:

mgmtp.a12.workflows.outbox.enabled=true

Documentation for this will be available under the Workflows Component soon providing more information and explanation.
Also use Eventlistener with DelegateExecution like this:

    @EventListener(condition = "#delegateExecution.getEventName().equals('start')")
    private void onTaskComplete(DelegateExecution delegateExecution) {
        String elementType = delegateExecution.getBpmnModelElementInstance().getElementType().getTypeName();

        if (elementType.equals("exclusiveGateway")) {
            syncAvailableFieldsDelegate.execute(delegateExecution);
        }
    }

Hi @jan-static-daemon ,

Thanks for you info, I will give it a try