1
votes

I am lookin for some articles in internet, googling, but so far have found nothing too explicit about my need.

I want to do a - for my perception - not so simple evaluation of a case.

rule "Send email E-mail based on rule evaluation"
/*
If  
    kind is equal 1 or 2 AND 
    code is equal 1 or 341 AND
    payment is equal S
    I do whatever I need to do
*/
when
    $item : Item((kind == 1 || kind == 2 ),(code == 1 || code == 341),payment = S);
then
    //do whatever I need to do
end

The difficulty is to add a new evaluation condition that works like a date limit (latest business day and hence it is not static) and must be supplied by my code to feed the rule (using kSession.insert ?) and then compare if a issueDate from item is smaller (is a date before my latest business day supplied) to do whatever I need to do.

Is it possible? How?

1

1 Answers

0
votes

This depends on how issueDate is represented. Let's say it is represented as an integer yyyyddd, where yyyy is the year and ddd the day within the year, then you create another class Limit with a field day (same type and format), insert an appropriate object and write your rule

rule "issue Date"
when
    Limit( $day: day )
    Item( kind == 1 || == 2, code == 1 || == 341 , payment == 123,
          issueDate < day )
then
    // ...
end

Of course, many other representations of a date would work just as well.