Select Page

Rule Application Patterns: Vocabulary & Independent Rule Sets

by | Last updated on Feb 21, 2023

A couple years ago I wrote a blog post that highlighted an excellent irAuthor method which adds a member to a collection of messages in a ruleset using a Vocabulary template. While that blog post and that pattern is highly useful even to this day, I came across a limitation in that technique recently which prompts an improvement. The problem? It’s not possible to use that vocabulary template at all entity levels in irAuthor.

Now it IS possible to add a universal add collection member vocabulary template at the application level (signified by the blue A from the Add Vocabulary option). But what if you’re interested in more flexibility in your output than just an add collection member template? Perhaps you’d also like to fire a notification as part of the output actions.

The New Pattern: the Case for an Independent (Rule Set)

In order to create an execute rule set vocabulary template that works at all levels (entity contexts) of a rule application, that vocabulary template needs to be created at the application level (and the rule set needs to be in an independent context). This new pattern variation is similar to the old pattern, but there are a few key differences. These differences have been highlighted in blue below. I’ve also included some relevant screen shots for reference.

    1. Create an entity (ex: “Error”) to contain the output messages with any desired output fields
    2. Create a collection of that entity off of the top-level entity (ex: “Errors”). Here’s a sample data structure to represent this:

Entity data structure

    1. Create an explicit rule set in an independent rule set context (ex: “AddOutputMessage”) which contains parameters
    2. Add a parameter to that rule set of the name and data type of the top-level entity:

Add a parameter to that rule set

  1. Inside of the AddOutputMessage rule set, add an Add Collection Member rule that uses those parameters as inputs to the Errors collection
    1. Also: add any other rules that you’d like to have executed when this rule set runs (ex: a fire notification)
  2. Create a vocabulary template at the application level context which executes that AddOutputMessage rule set; ensure that the top-level entity parameter is completed by entering the top-level entity’s name in the parameters box

Create a vocabulary template

That should do it! Let us know if you have any trouble getting this pattern to work, or if you have questions. Best of luck!

BLOG POSTS BY TOPIC:

FEATURED ARTICLES:

STAY UPDATED ON THE LATEST FROM INRULE

We'd love to send you monthly updates! Learn about our webinars and newly published content by subscribing to our emails. We'll never share your email address and you can easily unsubscribe at any time.