variableManager.fetchVariable return not serialized value

Hi! I setup Kotlin+spring boot+ camunda and try to use embedded forms.

i have class:

class BusinessTrip() : Serializable {
var from: String? = null
var to: String? = null
var dateFrom: Date? = null
var dateTo: Date? = null
var reason: String? = null
var totalAmount: Double? = null
var fly: Fly? = null
var hotel: Hotel? = null
var status: BusinessTripStatus? = null
var employee: String? = null
var amount: Long? = 0
}

i setuped org.camunda.spin.spi.DataFormatConfigurator to use my custom Jackson serializer with kotlin library.
I try fetch variable ‘trip’ from context on form like this:

camForm.on(‘form-loaded’, function() {
camForm.variableManager.fetchVariable(‘trip’, deserializeValues);
});
camForm.on(‘variables-fetched’, function() {
$scope.trip = camForm.variableManager.variable(‘trip’);
console.log($scope.trip);
});

i see that browser call this method:
http://localhost:8080/api/engine/engine/default/task/e3ab9b10-a99b-11e9-8657-d43b04123161/form-variables?deserializeValues=false&variableNames=trip
in return i get
image

But i want it serialized( deserializeValues=true i guess?).

If i call this from postman, i get:

What i missed? How i can get serialized object ?

Hi @kotskin,

you missed nothing, the camForm always fetches serialized values[1]. You have 2 possibilities to get around this problem:

  1. Fetch the values yourself. You can get the taskId form camForm and then create a REST request without using the variable Manager.
  2. Customize the webapps. You can change the file linked below and use it to build your own modified Tasklist.

[1] https://github.com/camunda/camunda-bpm-sdk-js/blob/master/lib/forms/camunda-form.js#L576-L597

1 Like

Great, src of camunda-form.js is helpful. How other examples, like this, https://github.com/camunda/camunda-bpm-examples/tree/master/usertask/task-form-embedded-serialized-java-object, work?
What mechanism used to transform serialized value to $scope (native js json i think)? Becouse when i want to work like in this emaxple, in $scope.trip.value i get only serialized string, so i cant do nothing with this (or not?)

I think the difference is that the serialization Format in the example is application/json instead of x-java-serialized-object, so it is possible to parse it on the client side.

1 Like

Yeah, look like this. So if i can serialize my object to application/json by default, example will work for me. Great, thank you for the advice!