As part of a Call Activity, we need to generate an applicable Business Key from a variable that’s passed in when instantiating the parent workflow instance. So for example, given a variable says objects:
{“objects”: [{“id”: “48d00a32-c7da-4171-bb4c-dfde75a418c2”, “type”: “box”},
{“id”, “5c9a44c6-85c0-4176-8336-b13111a5aded”, “type”: “content”}]}
What we need to do in one case is generate a business key based on the first element in the list. To send the objects variable value into Camunda, we encode it as a string and just set the type to String. Tried using Object and maybe that would be better but ran into problems with setting the objectTypeName and serializationDataFormat.
Fortunately, using Spin we can deserialize the string back to JSON although it’s then in a Jackson JSON Node instead.
So what we want as an end result is this:
48d00a32-c7da-4171-bb4c-dfde75a418c2
This doesn’t work
#{S(execution.getVariableTyped(“objects”))[0][“id”]}
Cause:
Unknown method used in expression: #{S(execution.getVariable("objects")).get(0).prop("id")}. Cause: Cannot find method get with 1 parameters in class org.camunda.spin.impl.json.jackson.JacksonJsonNode
How then can this be used to extract the required data to construct the desired Business Key?