Search code examples
expressionapache-nifi

Nifi Expression Language how to assign a value to a variable


I'm using Nifi's Expression Language to compute 2 dates in order to stick them into a template. I like compute these dates ONCE and to use them into the template as much as I need. My Idea is to do something like:

dateStart = ${now():toNumber():minus(86400):format("YYYY-MM-dd'T'hh:mm:'00'")} 

then use ${dateStart} as I like

How can I assign the expression result to a var ?


Solution

  • The UpdateAttribute processor is used to add attributes to flow files. From the configuration screen of UpdateAttribute you can click the + icon in the top right to add a property and name it "dateStart" and set the value to your expression. After that you can reference ${dateStart} in other processor properties that support expression language.