It's a bit diffcult to understand your post - could do with being a bit more clear.
RouteOnAttribute takes one or more Dynamic Properties with some Expression Language that must evaluate to True or False.
If the Dynamic Property's Expression Language evaluates to True, the FlowFile is directed to a Relationship with the name of the Dynamic Property.
If the Dynamic Property's Expression Language evaluates to False, it will try the next Dynamic Property (if there is one) - if there are no more Dynamic Properties left, and all have returned False, then the FlowFile is sent to the unmatched
Relationship.
If your data is always either null/empty (Negative) or contains 3 chars (Positive) then there is no need to check for both conditions - simply check for either the Negative or Positive condition.
E.g.
One Dynamic Property called valid
with the expression ${CURRENCY_CD:length():equals(3)}
With this configuration, all FlowFiles where CURRENCY_CD
has 3 characters will be routed to the valid
Relationship. All FlowFiles that do not have 3 characters, including null/empty, will be routed to the unmatched
Relationship.
With that, the following would happen:
CURRENCY_CD
= TRI
goes to valid
CURRENCY_CD
= null
goes to unmatched
CURRENCY_CD
= testing
goes to unmatched
(we are assuming here that this won't be present in your data)
If you can't make that guarantee and some data might fall outside of those 2 conditions, you could add a second Dynamic Property named empty
with the expression ${CURRENCY_CD:isEmpty()}
. This would route all null/empty FlowFiles to the Relationship empty
.
With that, the following would happen:
CURRENCY_CD
= TRI
goes to valid
CURRENCY_CD
= null
goes to empty
CURRENCY_CD
= testing
goes to unmatched
It's hard to tell from your post, but if both empty/null and 3 characters are the Postive condition and you want to validate for both in one Expression then you can simplify your Expression to this:
${CURRENCY_CD:isEmpty():or(${CURRENCY_CD:length():equals(3)})}
Which would return True for both empty/null or 3 characters and forward them to the same Relationship.
With that, the following would happen:
CURRENCY_CD
= TRI
goes to valid
CURRENCY_CD
= null
goes to valid
CURRENCY_CD
= testing
goes to unmatched