emilkhay
emilkhay

Reputation: 33

Accessing the parameter by dynamic name

How to access the parameter #{...} in Process configuration field if its name needs to be changed dynamically (for example, the name of this parameter is contained in some FlowFile attribute OR the name generating using expression language).

Illustrative example – for the LogMessage process, I have prepared several parameters in (msg1, msg2, msg3 etc.) that I would like to output depending on the attribute numofmessage

Field Log message for LogMessage process

Upvotes: 1

Views: 1156

Answers (2)

user15427102
user15427102

Reputation: 11

You can do it using evaluateELString()

${literal('{dynamic_${name}}'):prepend('#'):evaluateELString()}

Upvotes: 1

Bryan Bende
Bryan Bende

Reputation: 18670

Currently you cannot use EL inside of a parameter reference. If you put something like #{${abc}} it will look for a parameter named ${abc} and won't find one so it will be invalid.

You can only do the reverse, use parameter inside of EL, for example ${ #{abc}:replace('xxx', 'zzz') }.

In general, parameters are meant to be a better version/replacement for the existing variables functionality, but in this case variables may work better for you since variables are referenced through EL.

Upvotes: 0

Related Questions