Accessing indexes and entries of input list from DMN

Hello Camundeers,

Following some official DMN tutorials and online resources, I could run DMN decisions for input lists using FEEL expressions, where list size such as count(listName) = number and in case of a simple string list, contained entries as list contains(“A”,“B”) can be calculated.
Is there a way to access to single indexes of the lists like someList.get(i) or someList[i] and access further to the fields of list entries, like someList.get(0).someField in the DMN input?

Example Input Definition:
image

DMN Input:
image

It would be great if someone can provide a DMN example. Thanks in advance.

Cheers
Tunch

Hi @tunch :wave:

Regarding your question:

Yes. You can access an element of the list by its index, starting from 1.

someList[i]

A property can be accessed using a path expression. Either on the list itself or on the element of the list.

someList[1].someField
// or
someList.someField[1]

Does this help you?

Best regards,
Philipp

Hi @Philipp_Ossler! Thanks for you reply. I followed at first the official documentation you referred and tried to access the list as in your suggested solution. However I received the error:

failure: end of input expected
      >  input.someList[0].someField

Trying to use the use a get call as I mentioned before someList.get(0).someField ended with another error

java.lang.IllegalArgumentException: wrong number of arguments

Finally I could solve the my problem but utilizing the second variant, i.e. someList.get(0).someField and JUEL expression language instead of FEEL .

Ah, I see. This is a current limitation of the parser. The following FEEL expression should do the trick:

(input.someList[0]).someField

Sorry to say but it didn’t help. I received the same errors. I just use JUEL for now although I was hoping, using FEEL one could achieve accessing list elements.

Thanks in any case.

:thinking:

Which Camunda version do you use?

7.14 Enterprise / Springboot

Ok. The expression should be

(input.someList[1]).someField

In FEEL, a list starts at index 1 (not 0 like in other programming languages).

Looking at your DMN example, you should also check the input entry. !55 is not a valid FEEL unary-tests expression. A negation must be written as not(55).

Does this help you?

Hi @Philipp_Ossler , it simply does not work with FEEL irrelevant of where I put the parantheses, dots and so on. I keep on getting:

java.lang.IllegalArgumentException: wrong number of arguments

For my use case, where I need to access lists of POJOs, I will need to use JUEL. It’s a pity that such an advertised and seemingly widely used EL, is so difficult to use for a simple operation like list access.
p.s. The problem of !55 is clear, should be not(55) forgot to update the screenshot. This part is not an issue.

Hi @tunch ,

in case you still want to switch back to FEEL or anyone else runs into this problem like myself:

indicates that the call of .someField calls a method that has the same name as the field that you want to acess but has a different number of arguments ( != 0 ) .

If your POJO has a fluent Interface that returns an instance of this object but expects an argument like:
public YourClass someField("fieldValue) {...}
then it is possible, this method is accidentally called instead of accessing the value of someField.

In my case I had to rename or remove my fluent builder for this POJO in order to deal with the IllegalArgumentException.

Best Regards
David

1 Like