Unexpected variable types when starting process instance with form

Hi all,

I deployed a process definition and forms definition into Flowable REST. My process will use variables with different types: string, long and date.

To create a process instance, I use a REST call similar to:

curl --user user-vacation-employee: -H “Content-Type: application/json” -X POST -d ‘{ “processDefinitionId”:"", “properties”: [ {“id”:“numberofdays”, “value”:“15”, “type”:“long”}, {“id”:“startdate”, “value”:“2018-08-16”, “type”:“date”}, {“id”:“vacationmotivation”, “value”:“Holidays”}]}’ http://localhost:8084/flowable-rest/service/form/form-data

But when I retrieve variables of my process instance, they are all as string and my JavaDelagate classes fail because of a casting error

curl --user rest-admin:test http://localhost:8084/flowable-rest/service/runtime/process-instances/786f2d4d-9be8-11e8-8d0c-764a637a06c2/variables
[{“name”:“employeeName”,“type”:“string”,“value”:“user-vacation-employee”,“scope”:“local”},{“name”:“numberofdays”,“type”:“string”,“value”:“15”,“scope”:“local”},{“name”:“vacationmotivation”,“type”:“string”,“value”:“Holidays”,“scope”:“local”},{“name”:“startdate”,“type”:“string”,“value”:“2018-08-16”,“scope”:“local”}]

How to set process instance variable with the right type when starting a process instance with a form ?

Thanks for your help
Christophe

Hi all,

Can someone confirm me that it is a wrong usage of the REST API or a problem in the REST API starting process instance that not take into account the variable type ?

According to the source code https://github.com/flowable/flowable-engine/blob/flowable-6.3.1/modules/flowable-rest/src/main/java/org/flowable/rest/service/api/form/FormDataResource.java, it seems that the variable type is not taken into account.

If confirmed, I will prepare a fix.

Thanks for your help,
Christophe

Have you tried passing the value of numberofdays as a long, that means, without the double quotes?

 {“id”:“numberofdays”, “value”:15, “type”:“long”}

Thanks @inakihn but symptoms are the same with your proposal.

IMO, this REST API does not convert variables in the right type. I will try to do a fix.

Regards,
Christophe

Hi Christophe,

The form properties provide a very basic implementation to work with forms. The form definition JSON support we added afterwards is a lot richer and more flexible than form properties.
The behaviour you are seeing is I think correct with how form properties are implemented. The form values are always transformed to string. So when retrieving the process variables the values will be returned as a string. For example the LongFormType can be used to transform the string to the correct Object type -> https://github.com/flowable/flowable-engine/blob/master/modules/flowable-engine/src/main/java/org/flowable/engine/impl/form/LongFormType.java

Best regards,

Tijs

Hi @tijs

It’s acceptable to return process variables as string even if it will be better to take advantage of attribute type. But, IMO, the attribute ‘type’ must be used to convert the variable value when creating a process instance.

Do you think the same thing about conversion of the API creating process instance ?

Regards,
Christophe