In the rule studio , while verbalizing a BOM object , there is checkbox called "Generate Automatic Variable" , what would be its purpose ? Is it a global variable ?
2 Answers
Automatic variables are there for you to access the working memory object directly via the verbalization.
It based on the usage you want to use :)
there is no better way than an other.
if you want to populate the working memory and let the engine deal with the manipulation then you can use automatic variables
If you want to control everything then use rule variable (pre conditions - starting with "definitions")
It can depend on how business users want to create/author rules, as well
The doc says:
Because objects in the working memory cannot be named or
verbalized, you must bind them to rule variables or automatic variables
by defining a pattern in the definitions of the rule artifact to manipulate
them
– At run time the rule engine cycles through all the objects in working memory to
find objects that match the definition of the rule variable
– The rule engine creates a separate rule instance for every match, which works
on the object that caused that particular rule instance to be created
• You can also use rule variables simply to enhance the way your rules
are written
– For example to reduce the length of your conditions or your actions when you
author rules, or to define a constant used in the rule
I have been using JRules for years and it all depends on the design you want to implement.
As a JRules instructor, I would say: Pick up what you prefer but personnally I don't use them. Except quick POCs.
Hope it helps

- 1,401
- 9
- 4
It is more like a global variable which can be accessed anywhere in the rule project.
Please Refer to the documentation especially the section about the setup of automatic variables
-
for more clarification , suppose i have Person class and Employer class.I have verbalized them as the person and the employer , but I made the person as automatic variable. So you mean to say , I cannot access 'the employer' anywhere in my rules ? , I don't think so. – Tito Mar 16 '12 at 02:54
-
Unless you verbalized Employer BOM as Input/Output/InOut parameters or variables. In simplistic java terms we can say automatic variables are Singleton instances of the BOM. – phanij Mar 16 '12 at 20:31
-
what if I make employer as IN param and verbalize it and then make it as automatic variable too. what difference does it make.still im not clear about the usage.if u can briefly explain using an example ? like when to use automatic variable, scenarios. – Tito Mar 17 '12 at 14:00