Recommended approach for storing form data

Hi,

I would like to know what is the recommended approach for storing form data in a task. I don’t want to complete the task, just to save the current form as task variables, imagine that there is a save button in the UI, something like that.

My current approach is to update the variables of the task indicating scope=local. The problem I’m facing is that, when the variable already exists, an exception is thrown:

curl --location 'http://localhost:9090/flowable-rest/service/runtime/tasks/26e32f3b-3ac0-11f0-8f27-0242ac140005/variables' \
--header 'Content-Type: application/json' \
--header 'Authorization: ••••••' \
--data '[
    {
        "name": "legalName",
        "type": "string",
        "value": "ABC DEF Corp",
        "scope": "local"
    },
    {
        "name": "tradingName",
        "type": "string",
        "value": "ABC DEF Corp",
        "scope": "local"
    }
]

{
    "message": "Conflict",
    "exception": "Variable 'legalName' is already present on task '26e32f3b-3ac0-11f0-8f27-0242ac140005'."
}

Is there a better approach?. I would also like to store the form as local variables of the task for audit purposes, that way I would also know what form fields has been changed at what task.

Thanks a lot for your help!
Regards.

Hi Antonio,

I would recommend 6.8.+ implementation of

org.flowable.ui.task.rest.runtime.TaskFormResource#saveTaskForm
and
org.flowable.ui.task.service.runtime.FlowableTaskFormService

removed in 7.+

Regards
Martin