Re: Undo action doesn't work the first time the condition is cleared, works the second time

47 views
Skip to first unread message
Message has been deleted

Sergiy Nikolayev

unread,
May 24, 2019, 12:00:01 AM5/24/19
to NRules Users
The best way to debug this is to create an isolation repro scenario. Construct the fact objects, insert them into a session and demonstrate the behavior.
One thing to note about Undo actions, is that they are called only when you call session.Fire. Can you please confirm that when you are changing the conditions and expect the Undo to get called, you are calling the Fire method?
Message has been deleted
Message has been deleted

Sergiy Nikolayev

unread,
May 28, 2019, 11:37:40 PM5/28/19
to NRules Users
I would be very happy to help troubleshoot this, if you can create a repro scenario

Mike Doonsebury

unread,
May 29, 2019, 8:08:04 AM5/29/19
to NRules Users
I believe the problem was with my understanding of the Yield method.  Yield seems to work existentially on facts: if a rule is matched, then a fact is added automatically.  If a rule isn't matched, then that fact is automatically removed from the working set.  My scenario was different.  I had a price change.  So all of the facts were already in the working set, I just had a situation where one of the facts was changed and I was expecting that to trigger a rule.

The proper solution appears to be manually checking to see if the fact exists, inserting it if it doesn't, updating it if it does.  This seems to properly trigger the next rule in the chain to evaluate when the price is updated.
Reply all
Reply to author
Forward
0 new messages