Is it possible to define an expression in the conditional column header in a decision table?

258 views
Skip to first unread message

Ravi Mangalagiri

unread,
Mar 3, 2022, 12:15:40 PM3/3/22
to Kogito development mailing list
Hi Kogito Team,
Is it possible to define an expression in the conditional column header in a decision table?

I have a student object which has a list of courses. In my decision table can I have

count(student.courses[?]) > 0 as condition header and have the cell value as "Math"?
Screen Shot 2022-03-03 at 12.13.55 PM.png

--
Ravi Mangalagiri
703-505-4240 (c)

Matteo Mortari

unread,
Mar 3, 2022, 12:59:31 PM3/3/22
to Kogito development mailing list
Hi Ravi

> Is it possible to define an expression in the conditional column header in a decision table?

Yes, it's possible to have a generic FEEL expression in the table header, so instead of just resolving a symbol (a subdecision, etc.).


That could be useful to make a simple calculation etc.

The problem in your screenshot is that the ? "magic variable" is naturally not available in the header itself, since the Decision Table Header accepts an Expression,
while ? "magic variable" is only available in the body of the decision table input entries, as those accept Unary Test (or extended Unary Test when a ? is present).

In general I would NOT recommend getting over-complicated expressions in the Decision Table Headers, as a better Methodological approach would be to create a subdecision or better capture/encapsulate the logic in a context entry before the table itself.

Hope this clarifies,
MM

--
You received this message because you are subscribed to the Google Groups "Kogito development mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kogito-developm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kogito-development/CALg%3DC8M_r-7vTn3Z5Rv%2BWucgSNAFBFeJaPO9_F49ux_6pgRMAA%40mail.gmail.com.


--

Ravi Mangalagiri

unread,
Mar 3, 2022, 3:07:21 PM3/3/22
to Kogito development mailing list
Thanks for the response, Matteo. So the table looks like the following as you suggested...Screen Shot 2022-03-03 at 3.05.10 PM.png





--
Ravi Mangalagiri

Ravi Mangalagiri

unread,
Mar 4, 2022, 1:38:18 PM3/4/22
to Kogito development mailing list
Matteo,
Based on this approach, the condition columns keep growing and the table gets hard to manage. Do you have any thoughts?
--
Ravi Mangalagiri

Matteo Mortari

unread,
Mar 5, 2022, 3:31:10 AM3/5/22
to Kogito development mailing list
Hi Ravi,
I assume you mean the number of columns will grow linearly to the number of "course name"(s) you are interested in capturing with the logic.

A possible refactoring to make this scalable could be the following.

Defined a BKM "follows(s: Student, c: String)" with the logic:
count(s.courses[c]) > 0

This BKM can be used anywhere in order to check if the given student in the parameter, follows the course given in the parameter.
Ensure this BKM is also listed in the knowledgeRequirements of your table.

Then the table column is just student, and the content of the input entries in the table for the same column could be as such:
follows(?, "Math")
follows(?, "Science")
etc. based on your first table example

Hope this helps,
MM

Ravi Mangalagiri

unread,
Mar 5, 2022, 8:20:05 AM3/5/22
to Kogito development mailing list
Awesome. I got it working and attached a sample dmn for the context of the thread.
Screen Shot 2022-03-05 at 8.19.03 AM.png

student.dmn
student.http
Reply all
Reply to author
Forward
0 new messages