Some of my Rules (say they are part of a collection S) execute in their actions Rules components of the following form: If conditions A and conditions B, then do actions. Now, conditions A and actions are always the same; only conditions B changes according to the particular Rule in S.

It is frustrating to add the same conditions and actions to the Rules components every time. Therefore, my idea is to enclose every conditions B in a Rules conditions component, and then use those components as a variable in 1 "abstract" Rules component that captures the above pattern. Is that possible?


This answer provides a way to capture the following common pattern for Rules: "If conditions A and conditions B, then do actions" for fixed conditions A and actions. Instead of creating a separate condition set component for every conditions B (and then use those components inside some kind of "abstract" Rules component as a variable), the following approach is way easier:

  1. Create a condition set component for conditions A, say My component for conditions A.
  2. Create an action set component for actions, say My component for actions.
  3. For every conditions B, create a new Rule.
  4. For every new Rule, add My component for conditions A to the conditions, and My component for actions to the actions. Then, complement the conditions with conditions B.

Result: we fixed the never-changing conditions A and actions in 2 Rules components. That saves us a lot of redundant repetitive work. If we want to implement 10 cases of the general pattern, then we end up with 10 Rules + 2 Rules components = 12 Rules in total.

Let's compare this approach with the initial idea. We would have to create 10 Rules components for the conditions B + 1 "abstract" Rules component + 10 Rules that contain this "abstract" Rules component in their actions = 21 Rules in total.

The advantage of the proposed alternative approach is less Rules in total. The disadvantage is that every Rule needs to include the same action set and condition set components. But to be honest, adding those 2 components to the Rules takes much less clicks and time than creating new Rules... I think this problem nicely illustrates the power of action sets and condition sets in the Rules module (a feature that might seem somewhat obscure for beginners).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.