Using FEEL , does it support "contains" feature in DMN table, tried JUEL but not working

Working on DMN table, need to know if FEEL supports “contains” functionality.
Also, would like to know if I can get the count of matches as one of the input column.

Tried to use JUEL expressions instead FEEL but not working. Any help will be appreciated.

Kindly advice

Has any one used JUEL expressions to use contains functionality? Not able to add a rule having contains feature in DMN table . Kindly advice.

Hi @SandyaMulijogi,

please have a look at the related topic: How to Implement String.contains method in DMN table

Does this help you?

Best regards,
Philipp

I had referred to those related topics as well but didn’t work . Still get error as shown below
FEEL-01007 Unable to resolve function ‘contains’ in expression 'contains(CaseType,“BCNR”).

Also, I want to check if I can check against list of strings like (CaseType,“BCNR, RECALL”).Can I do this in one expression or need to add a separate rule for each String that I want to check. The list can grow big up to some 50 to 100 strings. any suggestions please.
For exact match, I was able to do but not for “contains”

Attached, the dmn table for your reference.

'SwiftCaseType.dmn (1.6 KB)

JUEL expressions are working for one string as shown below

Is there a way to check against list of strings in one rule instead of multiple rules for each String .

e.g> Have list of Strings {“BCNR”,“RECALL”,“BCNR2”} , is there a way to check if variable CaseType contains one or more Strings in list.

Any help appreciated
SR

Hi @SandyaMulijogi,

the default FEEL engine doesn’t support a contains function. If you use the FEEL-Scala engine then you can write contains(CaseType,"BCNR"),contains(CaseType,"RECALL") (i.e. a disjunction) or matches(CaseType, <regex>) as condition of an input entry. Or you can write an expression like some type in ["BCNR","RECALL"] satisfies contains(CaseType,type)

However, if you want to check against 50 or more strings in a single expression then this expression will be neither readable nor maintainable. Maybe you can externalize the check or split it into multiple decisions / conditions.

Best regards,
Philipp

1 Like

Thank you very much for the response.
Sandya

sorry for reviving this old thread but I have exactly the same problem and can’t get it to work even though FEEL-Scala is now the default implementation used by Camunda DMN engine.

I have a decision table with an input parameter that contains a List of Strings, and I want to check if it contains a list of expected items.

So far, regardless of what I do, I always get this error:
org.camunda.bpm.dmn.feel.impl.FeelException: FEEL/SCALA-01008 Error while evaluating expression: failed to evaluate expression '"true"': expected Boolean but found 'ValString(true)'

Let’s call the input value damageTypes, my expression (as entered in the DMN modeller) is:
list contains(damageTypes,["car", "house"])
(according to FEEL-Scala docs, it’s “list contains” not “contains”, correct?)

I tried variations with just “contains” and with comparing to a single string, to no avail.
Any help would be greatly appreciated, thanks.

Hi @grexe :wave:

Your expression looks good so far.

The failure message

org.camunda.bpm.dmn.feel.impl.FeelException: FEEL/SCALA-01008 Error while evaluating expression: failed to evaluate expression '"true"': expected Boolean but found 'ValString(true)'

seems to indicate that something else is not correct.

Please share your decision table and the variables that you’re passing it :slight_smile:

I’m afraid I cannot really post the code here since it’s company internal, but I just have 5 input parameters (2 boolean, 3 Strings), and only need to check a String parameter (passed as list) against a list of expected values.
Which expression is correct then? “list contains” or just “list”?

@grexe you can provide the reproducible code for that issue.

list contains() is what you’re looking for :wink:

The failure message says that it expects a boolean value but found the string "true". Maybe, there is something wrong with the types, or how they are defined in the decision table. For example, a boolean value is defined as type “string” in the table instead of “boolean”. (https://docs.camunda.org/manual/7.13/reference/dmn/decision-table/input/#input-type-definition)

1 Like

thanks @Philipp_Ossler, I tried to reproduce the error in a simple test table, but with all input parameter types I need to cover, including the list of Strings and the FEEL expression, but there everything worked as expected. :confused:
However for some reason, the DMN simulator won’t load it, but only show an empty inputs/outputs field and the demo tables; the remaining page is empty.

turns out the Enums I mapped with PropertyUtils are now Objects and my Enums name is UPPERCASE, but since toString() turns them lowercase, this was really hard to spot in the debugger…
Even inside the DecisionTable variable resolution, I could not spot uppercase names, almost magic;)
This works now, thanks still for all the input!

Sadly I cannot do a simple list check via [element], and I cannot check for sublist via list contains(inputParam, (["A"], ["B"])) , but have to combine two list containsviaand`.

I’m not sure that you mean by the following. Can you extract an example to demonstrate the problem?

Regarding:

You can check if a list contains multiple items using the following expression:

every x in ["A", "B"] satisfies list contains(inputParam, x)

What exactly do you mean by the following statement?

1 Like

Hi,

Sorry for jumping in the discussion.

I want to check if the list which i am passing is equal to the list of attributes defined in dmn.

My input will be like: [A, B]

it should match to dmn input if and if only it has A and B only.

I have already tried contains, but that doesn’t solve my purpose.

Any help will be highly appreciated.

Hi @sachin_khanna.

In your case, the list contains() function should also work. Additionally, you can combine it with the count() function to check if the lists have the same size.

An equals check for lists will also be available soon:

Thanks @Philipp_Ossler.
Right now i am using below:

every x in [“APPLE”, “BANANA”] satisfies list contains(fruits, x)

how can i combine it with count() function?

It will be great help, if you can provide syntax or any example.

I have used below now with count function:

every x in [“APPLE”, “BANANA”] satisfies list contains(fruits, x) and count(fruits) = 2

It’s working for me.

Thanks @Philipp_Ossler for help.

Please let me know if i can improve my expression.

1 Like

Looks good :+1:

1 Like