[rules-users] Global variable in LHS

Swindells, Thomas TSwindells at nds.com
Mon Jul 18 14:55:27 EDT 2011


Don't use a global, instead create a new fact type "Global" having a single field globalVariable (type object will probably do), then you can pretty much write what you have below (once you add the missing bracket).
Alternatively you may be able to do something like eval(Arrays.asList("X", "Y").contains(globalVariable))

Thomas

> -----Original Message-----
> From: rules-users-bounces at lists.jboss.org [mailto:rules-users-
> bounces at lists.jboss.org] On Behalf Of pamerida
> Sent: 18 July 2011 19:09
> To: rules-users at lists.jboss.org
> Subject: [rules-users] Global variable in LHS
>
> Hi everybody,
>
> I would like to analyze a global value in the LHS of my rule without using an
> eval, something like this:
>
>
>         global String globalVariable;
>
>       rule 'SI-002-NAD-6'
>       salience 5000
>       when
>       global (globalVariable in ("X","Y")
>       then
>       logger.log("[SI-002-NAD-6] Debe colocar la información del
> propietario del medio de transporte.");
>       end
>
> I cant use eval because it doesnt recognize the keyword "in", for example
> this code would throw me an error in the validation
>
>  global String globalVariable;
>
>       rule 'SI-002-NAD-6'
>       salience 5000
>       when
>       eval (globalVariable in ("X","Y")
>       then
>       logger.log("[SI-002-NAD-6] Debe colocar la información del
> propietario del medio de transporte.");
>       end
>
> any suggestions? thanks so much for your help :)
>
>
>
> --
> View this message in context: http://drools.46999.n3.nabble.com/Global-
> variable-in-LHS-tp3180063p3180063.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users


**************************************************************************************
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmaster at nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.

NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00
**************************************************************************************




More information about the rules-users mailing list