Hi Sam,
Probably your best bet would be to create a separate rule, which evaluates the function in
the RHS and inserts a fact encapsulating the results into working memory. That can be set
to no-loop or to have a negative match on the fact it creates.
rule "eval function"
no-loop
when
$request : RequestFact()
then
FunctionResult result = functionCall();
insertLogical(result);
end
rule "business rule"
when
$request : RequestFact()
$functionResult : FunctionResult()
then
// do something
end
… or something vaguely similar. This way your function call is only evaluated once, and
the business rule does not fire until the function has been evaluated.
Steve
On 6 Aug 2012, at 08:34, RulesUsers wrote:
Hey laune, I think we are mixing up the things.
My requirement is to call a method in an helper class, that in turn accesses
the db.
Currently i have done with
*/evel(functionCall() )/* //The return type of the method is boolean
*But the problem is, once the control enters WHEN part of the rule it making
multiple calls to this method ( checked by putting in SYSO statements). But
i want this call to take place once.*
So it will be very helpful, if any once can suggest me any other way to make
function call from when part.
Also tried with
/*$A : Boolean() from functionCall( )
eval( $A )*/
But the result is same.
Also please provide your inputs if it is not possible to handle the problem,
where in it make multiple function call.
Regards,
Sam
--
View this message in context:
http://drools.46999.n3.nabble.com/Calling-a-function-from-When-part-tp401...
Sent from the Drools: User forum mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users