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:
DMN Input:
It would be great if someone can provide a DMN example. Thanks in advance.
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 .
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.
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).
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.
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.