Neil P
Neil P

Reputation: 3190

NiFi: expression to test if attribute exists

I need to optionally use an attribute if it exists, in an expression. I know I can use ifelse to determine this, however the attribute name is printed as a literal if it doesn't exist.

What is the correct expression to test for this?

${MyOptionalAttribute:notnull():ifElse(MyOptionalAttribute,'my default value')}

Upvotes: 0

Views: 2891

Answers (1)

tonykoval
tonykoval

Reputation: 1230

Use a UpdateAttribute processor:

  • MyOptionalAttribute (dynamic property): ${MyOptionalAttribute:notNull():ifElse(${MyOptionalAttribute}, "default value")}

Upvotes: 1

Related Questions