Data Transformations in Camunda 8

We have a requirement to transform the data present in the process instance variables. Some of the data transformations are simple like transforming the date-time format while some involve making rest api calls. i.e. Assume the process instance variable value is a json like below

  "name": "John",
  "address": "Washington"
  "gender": 1,
  "city": 45

Here the value of the “gender” attribute needs to be fetched and passed a rest api call that returns the gender is text for e.g. MALE. Same applies for city.

Could someone please guide me on what are the different ways to implement such data transformations in camunda 8?


Hi @jgeek1 and welcome to our forums :wave:

If the transformations are static you can define them as input/output mappings on the element that provides the data (as output mapping) or on the elements that require the data (as input mapping). Input/output mappings can harness the power of FEEL to define such transformations as expressions.

For example, gender is probably a transformation that doesn’t change, e.g. 1 -> "MALE". You could define this mapping by using get value on a FEEL context that defines the mapping, e.g.

target: gender,
source: get value({ 
  1: "MALE",
  2: "FEMALE",
}, string(genderAsNumber))

Note that genderAsNumber must be converted to a string type in order to be used as the key in a context.

If the transformations aren’t static and require you to perform work like fetching data from an API, then you should do work in a job worker. The job worker can return the fetched data and provide it to the process instance. You’ll either need to implement your own job worker, or for simple REST API data calls you could use the community maintained GitHub - camunda-community-hub/zeebe-http-worker: Zeebe worker for HTTP calls.

I hope this helps :bowing_man: