How do I get a payload value in a FEEL expression?

Rich Puderbaugh: Hello, is it possible to use a process input parameter (zeebe:ioMapping) as a placeholder in a FEEL expression?

korthout: Hi @Rich Puderbaugh :wave: I’m not sure I understand your question. Can you elaborate what you’d like to achieve?

Rich Puderbaugh: I am try to evaluate a dynamic expression where the property it tests against is specified by a process input variable, in our case a serviceId This is set as input parameter to our sub process. Our sub process conditionally executes activities based on FEEL expressions. One of the expressions is checking against service specific metadata with a variable.

= foo.serviceMetadata.${serviceId}.completed = true

where I would like to substitute the input variable from the call activity for serviceId.

One of the call activities may set the serviceId = “service0” and another call activity may set the serviceId = “service1”, as input parameters. They each contain distinct metadata, such as completed status.

I hope this is making sense. Thanks for your prompt response.

korthout: This is possible with <Context Functions | FEEL-Scala value()>

Here’s an example with the|REPL

@ feel("get value(y, x)","{\"x\":\"service\",\"y\":{\"service\":\"yes\"}}")
&gt; yes
res9: Any = Some(value = ()) 

So in this example we read from the object y, it’s entry for service which is the value of x

korthout: I think, your example would be something like:

= get value(foo.serviceMetadata, serviceId).completed = true

Rich Puderbaugh: I saw the get value but didn’t totally understand it.

so - in your above example, if the serviceId process input parameter is service0, it will look for the service0 property within foo.serviceMetatadata and test against its completed flag?

korthout: Yup, that’s it exactly :+1:

Rich Puderbaugh: awesome. thank you some much. that is exactly what i was looking for. I really appreciate your help.

Note: This post was generated by Slack Archivist from a conversation in the Zeebe Slack, a source of valuable discussions on Zeebe (get an invite). Someone in the Slack thought this was worth sharing!

If this post answered a question for you, hit the Like button - we use that to assess which posts to put into docs.