Support Questions

Find answers, ask questions, and share your expertise

How to do Dynamic property naming in NIfi?

avatar
Explorer

I am assigning a value to "reasonId" and later using it as a dynamic property in other processor(ExractText).

 

ff.png

Now, I want to assign this as an dynamic property so that I can store some API response into this. Means reasonId value and Api response both should change evertytime. 

ff2.png

Here I want this [${reasonId}=(.*)] to be like this:-

6099 = Api response     (Everytime value of 6099 should change as it is a dynamic variable)

But,

I am getting it like this

${reasonId}=Api response

 

Why there is no 6099 instead of reasonId. Does it means Dynamic property assignment is not working properly? 

or I can use some jolt spec and all for this? 

 

Basically I want reasonId to hold its value 6099 and Api response should be store in 6099 instead of ${reasonId}. 

 

 

 

1 REPLY 1

avatar
Master Mentor

@anony 

You can not use NiFi Expression Language (NEL) in component property names. NEL can only be used in component property values and even then, only when the component property supports Expression language.

With ExtractText, any dynamic properties added will create a new FlowFile Attribute on the outbound FlowFile with an attribute name matching the property name "${reasonId}" and the attribute set the the capture group string extracted from the source FlowFiles content.

Without understanding yoru complete use case, it is difficult to offer alternative possible solutions.
Why is it important to set a FlowFile property name to a reasonID?  FlowFile attribute property names only mean something to NiFi.  So if you were able to create dynamic property names, then how would you programmatically use them later in your dataflow as FlowFiles will have a variety of Attribute property names?

If you found that the provided solution(s) assisted you with your query, please take a moment to login and click Accept as Solution below each response that helped.

Thank you,

Matt