Support Questions

Find answers, ask questions, and share your expertise

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()})}
           )}
     )
}