How to add string value to global variable defined as java.util.List in workbench

2,573 views
Skip to first unread message

Chirag Soni

unread,
May 24, 2017, 10:47:41 AM5/24/17
to Drools Usage
In my project scenario, I have some rules which provide the discount based on the condition and in action, am adding all the discount on the discount List (Global List).  
I want to do this in KIE-WB but I am not able to add value to the Global list through the Guided decision Table.
I have tried to do the same with the BRL Fragment in action part but not able to complete it.

I am sharing the screenshots of the DRL file which I have written on Drools editor and working fine.

Please help me to find out the way to add the value to the global list in Guided Decision Table(KIE)


Regards,
Chirag Soni
DroolsGlobalList.JPG

Toni Rikkola

unread,
May 25, 2017, 7:34:30 AM5/25/17
to Drools Usage
Hi,

#1 I made the global in the workbench global editor.
#2 Then I used BRL condition and action to make the rule "set list value to object" in your screenshot.




Toni
Auto Generated Inline Image 1
Auto Generated Inline Image 2
Message has been deleted

Chirag Soni

unread,
May 25, 2017, 1:40:45 PM5/25/17
to Drools Usage
Thanks Toni Rikkola for the prompt response.

I tried the way you suggested but the query was to add value to the global list so I can pass this global list to other rules. 
Requirement ->
  • discountList.add("String value"); operation in Guided Decision Table. where String value comes from Table Action column.
  • Can you please suggest me, How can we initialize our Global List in KIE-Workbench. As we do in Drools-IDE using kSession.setGlobal("discountList", list); in DroolsTest.java.

Toni Rikkola

unread,
May 26, 2017, 7:00:51 AM5/26/17
to Drools Usage
Ok. New try. Here is how you could add a value to list.
You need to add a BRL Action and use Free Form DRL. You can @{value} (for example) for the location where you want to insert the value given in the column.

For initializing the global. You could try having an initialization rule that just sets the global with a salience value that makes sure that rule is ran first. You can leave the condition side empty and just do the init in the action side.

Toni




Auto Generated Inline Image 1
Auto Generated Inline Image 2

Toni Rikkola

unread,
May 26, 2017, 7:02:02 AM5/26/17
to Drools Usage
Images were not included for some reason.

Auto Generated Inline Image 1
Auto Generated Inline Image 2

Toni Rikkola

unread,
May 26, 2017, 7:03:17 AM5/26/17
to Drools Usage
And still not in. Keeps showing them for me, tried renaming. Sorry for the spam.

Auto Generated Inline Image 1
Auto Generated Inline Image 2

Toni Rikkola

unread,
May 26, 2017, 7:04:46 AM5/26/17
to Drools Usage
And now I also see the previous ones that were previously not visible.

Time to start the weekend! ;-)
Reply all
Reply to author
Forward
0 new messages