How To Get Form Variables Data After Submitting The Form?

I am using flowable REST apis for creating task and getting its form and submitting it. After the completion of the form, I unable to find a way to get the form and also get its value field filled with data that I have submitted.

To get the idea of work flow , I pasting following endpoints according to right sequence to understand its flow.

  1. To get Task ID for the respective form: mmn-runtime/tasks?caseInstanceId={{case_instance_id}}

  2. To get form of the new task id: cmmn-api/cmmn-runtime/tasks/{{task_id}}/form

  3. Performing a POST request to send the data variables of the form: form-api/form/form-instances

  4. Performing POST request to submit form with action=complete: cmmn-api/cmmn-runtime/tasks/{{task_id}}

After completing the form with action=complete, I need to get all those variables of the form field.

I searched from the doc there is many of these similar thing but not exactly what I am looking for.
Is there any endpoint already present that will fulfill my requirement?

Hi,

If you want to fetch the complete form (a historic task instance with the populated form) you can use this endpoint;

bpmn;
process-api/history/historic-task-instances/{taskId}/form

or
cmmn;
cmmn-api/cmmn-history/historic-task-instances/{taskId}/form

Does this help?

Regards,

Yvo

Hello,

Thanks for the help first of all.
And yeah I have tried these ones but it is saying task ID does not exist and when I check from history tables they all are empty.

@yvo , we have mark the form complete that is action=complete in the body of the post request of:

  1. cmmn-runtime/tasks/{{task_id}}

When we are using those above provide API call for historical we are getting an error that is provided task_id doesnot exist and also when we check historical tables from database that whole tables are empty.

Is there any other steps that is missing ? that is required to populated that historical table other than markng submitting form action=complete with its respective task_id

Are you sure you’re looking in the right place?
When creating a task an entry is written both in the ACT_RU_TASK and in the ACT_HI_TASKINST. But; with only a start time and no end time.
When completing; the entry is removed from ACT_RU_TASK and the entry in ACT_HI_TASKINST is updated with an end time.

The complete REST call seems correct.
Something seems to be off creating the task.

Regards,

Yvo

@yvo,

if something is missing in creating task, following are the steps for creating task:

Getting latest case definition ID: cmmn-repository/case-definitions?key=risk-case&latest=true

Performing a post request in getting a new case_instance_ID by giving it case_def_ID: cmmn-runtime/case-instances

Giving this case_instance_ID for getting task_ID: cmmn-runtime/tasks?caseInstanceId={{case_instance_id}}

And then rest steps are mentioned above for getting form, etc using that task_ID.

What is the result of getting the task?

It is in below format:
{
“data”: [
{
“id”: “8”,
“url”: “http://localhost:8182/cmmn-runtime/tasks/8”,
“owner”: “owner”,
“assignee”: “kermit”,
“delegationState”: “pending”,
“name”: “My task”,
“description”: “Task description”,
“createTime”: “2013-04-17T10:17:43.902+0000”,
“dueDate”: “2013-04-17T10:17:43.902+0000”,
“priority”: 50,
“suspended”: true,
“claimTime”: “2018-04-17T10:17:43.902+0000”,
“taskDefinitionKey”: “theTask”,
“scopeDefinitionId”: “123”,
“scopeId”: “123”,
“subScopeId”: “123”,
“scopeType”: “cmmn”,
“propagatedStageInstanceId”: “123”,
“tenantId”: “null”,
“category”: “ExampleCategory”,
“formKey”: “string”,
“caseInstanceId”: “5”,
“caseInstanceUrl”: “http://localhost:8182/cmmn-runtime/case-instances/5”,
“caseDefinitionId”: “oneTaskCase%3A1%3A4”,
“caseDefinitionUrl”: “http://localhost:8182/cmmn-runtime/case-definitions/oneTaskCase%3A1%3A4”,
“parentTaskId”: “null”,
“parentTaskUrl”: “null”,
“executionId”: “123”,
“processInstanceId”: “123”,
“processDefinitionId”: “123”,
“variables”: [
{
“name”: “myVariable”,
“type”: “string”,
“value”: “test”,
“valueUrl”: “http://…”,
“scope”: “string”
}
]
}
],
“total”: 0,
“start”: 0,
“sort”: “string”,
“order”: “string”,
“size”: 0
}

And then I used ID as task_ID for further api call.

@yvo

One thing I have noticed is that when I create new task ACT_RU_TASK get that task_id with no end_time whiling ACT_HI_TASKINST is empty doesnot contain any.

But when I complete form by sending action=complete it removes that entry from ACT_RU_TASK but ACT_HI_TASKINST is still empty.

I think there is some step missing in getting history populated.

Do you have history disabled?

flowable.history-level=none ?

1 Like

@yvo where is this file located in which this line is located, is the a config file?

Can you share its location?

Depends on how you run Flowable.
It’s a property. This can set in various ways.
But this is not the default value. So if this is set; then it’s done explicitly.
For example in a application.properties file. Or passing it as command line arguments to the runnable war. Or as environment variables when running the Docker container… etc etc

Hey @yvo, Thank you for the help. Now the history tables have data.

Just tell me one thing how would I get the form values. Suppose the user has 10 fields on the form. It just only filled 2 of those and marked them as complete and jump on to the 2nd form. So for some reason, the user has to go back and edit the 1st form again.

So for the above case, we need two things first the values of the 2 fields which he had filled previously and how we update that previously filled form value?

Please post the rest API because we are using the rest API’s for flowable.

‘just going back’ is something that in most cases you either have to explicitly model in your process model.
Or you have to do some technical things. But it’s not a default case.
Escalation or verification is. In that case you model this step (user task with form) and populate the form assigned to the ‘second’ second step with the values of the ‘first’ completed step.

Also; Flowable UI provides the option to save a form. Perhaps this is something that could be used. Take a look at Flowable UI (and the corresponding backend code).

Yvo

flowable-rest/cmmn-api/cmmn-history/historic-case-instance/{{task_id}}/form

I am calling this API to get the form values it only returns me the form value when the task is not completed. After I marked it complete. It returns me null in form value.

Can you suggest me the form API to get that form value when the task is complete?

Thank you.

Do you mean /historic-task-instances/ instead of case-instance?

Looking at the code here https://github.com/flowable/flowable-engine/blob/master/modules/flowable-rest/src/main/java/org/flowable/rest/service/api/history/HistoricTaskInstanceResource.java#L94

It should give you data back, as it fetches the historical counterpart: https://github.com/flowable/flowable-engine/blob/master/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetTaskFormModelCmd.java#L67

What does that endpoint return? A 404? Something else?