Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Support Questions

Find answers, ask questions, and share your expertise
Announcements
Share your experience with Cloudera on G2 and get a $25 Amazon Gift card.
Hi, I'm CLEO! Something exciting is coming to the Community. Stay Tuned!

NiFi - Expression Language - trouble with nested and-/or-conditions

avatar
Master Collaborator

I'am struggling with Expression Language concerning nested and-/or-conditions.

In my UpdateAttribute the variable KONTO_IST_AN should be getting the result in boolean which is provided by this expression.


Sample content of RESPONSE (always exactly one element at one time):

[{"antauschbis":"20191231","antauschvon":"20190101","id":"(422)"}]  => expected result: true

[{"antauschbis":null,"antauschvon":"20190101","id":"(422)"}]  => expected result: true

[{"antauschbis":"20190531","antauschvon":"20190101","id":"(422)"}]  => expected result: false

[{"antauschbis":null,"antauschvon":"20200101","id":"(422)"}]  => expected result: false


Expression:

${RESPONSE:jsonPath('$.[0].id'):equals(${KONTO_BV}):
   and(${RESPONSE:jsonPath('$.[0].antauschvon'):le(${now():format("yyyyMMdd")}):
        and(${RESPONSE:jsonPath('$.[0].antauschbis'):ge(${now():format("yyyyMMdd")}):
              or(
            ${RESPONSE:jsonPath('$.[0].antauschbis'):isEmpty()})}
           )
     )
}

But there seems to by a syntax error because the attribute KONTO_IST_AN contains after execution of UpdateAttribute the above expression not the expected result.

Checked all square and round brackets and can't finde my error.

Could someone please tell me how to resolve this?

1 ACCEPTED SOLUTION

avatar
Master Collaborator

Got it! There was one } missing. Thought if the editor shows the expression coloured it would by syntactical correct.

So it has to be:

${RESPONSE:jsonPath('$.[0].id'):equals(${KONTO_BV}):
  and(${RESPONSE:jsonPath('$.[0].antauschvon'):le(${now():format("yyyyMMdd")}):
        and(${RESPONSE:jsonPath('$.[0].antauschbis'):ge(${now():format("yyyyMMdd")}):
              or(
            ${RESPONSE:jsonPath('$.[0].antauschbis'):isEmpty()})}
           )}
     )
}

View solution in original post

1 REPLY 1

avatar
Master Collaborator

Got it! There was one } missing. Thought if the editor shows the expression coloured it would by syntactical correct.

So it has to be:

${RESPONSE:jsonPath('$.[0].id'):equals(${KONTO_BV}):
  and(${RESPONSE:jsonPath('$.[0].antauschvon'):le(${now():format("yyyyMMdd")}):
        and(${RESPONSE:jsonPath('$.[0].antauschbis'):ge(${now():format("yyyyMMdd")}):
              or(
            ${RESPONSE:jsonPath('$.[0].antauschbis'):isEmpty()})}
           )}
     )
}