Here I was too hasty taking the Document pattern as granted. The
createError only fires if field1 *and* field2 are null/"", but the
initial statement says "...if *any* field is null...".
Therefore, you must use
when
not Error()
( Document( field1== null || == ("") )
or
Document( f
The rule shown below isn't correct. It will create an Error, but it
won't retract *all* Document facts as there may be some that do not
have field1 or field2 set to null/"".
-W
On 02/02/2012, Esteban Aliverti wrote:
> You could do something like this:
>
> rule 'empty documents'
> ...
> when
> $
rule "createError"
when
not Error()
emptyDoc: Document( field1== null || == (""), field2 == null || == ("") )
then
Error fact0 = new Error();
fact0.setErrorCode( "code1" );
insert(fact0);
end
rule "retractBadDocs"
when
Error()
$doc: Document()
then
retract( $doc );
end
-W
Did you try using Java dialect instead of MVEL?
Best Regards,
Esteban Aliverti
- Developer @ http://www.plugtree.com
- Blog @ http://ilesteban.wordpress.com
On Thu, Feb 2, 2012 at 11:47 PM, vadlam wrote:
>
> when
>
> $emptyDocs:java.util.List(size>0) f
when
$emptyDocs:java.util.List(size>0) from collect ( Document( field1== null ||
== ( "" ) , field2 == null || == ( "") ) )
then
//insert an error
Error fact0 = new Error();
fact0.setErrorCode( "code1" );
insert(fact0 );
for (int i=0; i < $emptyDocs.size(); i++){
You could do something like this:
rule 'empty documents'
...
when
$emptyDocs: List(size>0) from collect ( Document( field1== null || == (
"" ) , field2 == null || == ( "") ) )
then
//insert an error
Error fact0 = new Error();
fact0.setErrorCode( "code1" );
insert(fact0 );
//
Hi All,
we have a scenario whereby, several documents are created as part of the
ruleflow. at the end of the ruleflow, if any of the fields in the document
is empty or null, we would like to create a error (only one error) and
retract all the documents so far.
rule "createError"
rulef