Question

I have a requirement to set a new property (example: unique ID) to each and every rule and access it from action part of the respective rules during the execution. For example: If the age of person is more than 18 then set the output to the ID of the rule.

(Here ID should come from the new property being added.)

I am using IBM ODM 8.5. Please suggest what are all the ways get unique ID from business rules?

In the B2X mapping of virtual method, I printed the rule.properties map using instance.getRule().properties. I was expecting custom properties and all other rule properties. However, the properties map only had a handful of following six:

key: ilog.rules.business_name value: test score

key: ilog.rules.package_name value: check score

key: requestorMail value:

key: status value: new

key: ilog.rules.package value: check_score

key: ilog.rules.group value: check_score.test_score

Was it helpful?

Solution

You can customize rule model with Model extension and add your custom property (YOUR_PROPERTY_NAME) to the rule artefact.

You can acces this by adding a virtual method (static method in the BOM! don't use a xom! simply add it with the BOM editor) verbalized YOUR_VERBALISATION.

  • In the method implementation (B2X), you can get the value with the instance.getRule().getPropertyValue("YOUR_PROPERTY_NAME"); (instance is a runtime variable containing the IlrRuleInstance of the current Rule)
  • In the action part use YOUR_VERBALISATION to call the method.

OTHER TIPS

Another approach you could use is to create your set of variables (Variable Set). Within a Variable Set you define:

  1. The name of the variable
  2. The type of the variable
  3. The verbalization for this variable
  4. (Optional) The initial value for this variable

It's easy to create and it's accessible to any part of you Rule Application or Module.

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top