Hey fago and all,
In my work with Berdir on Private Message module rules integration, we've created a rule on the "Message is sent" event that fires a "Load number of unread messages" action. This is working successfully according to debug messages.
But when we try to create a subsequent rule that would do a data comparison condition on the "number of unread messages" (also on the "Message is sent" event), we find that this variable is not available for use with the condition. (It does not appear as an available data selector.)
So I'm thinking this may be a bug related to conditions not displaying variables loaded by actions.
I'm posting this as a bug report, but it is possible this could be a support request (if I'm somehow not configuring this properly in 7.x-2.x) or feature request (if this is not yet supported in 7.x-2.x).
Thanks,
Ben
Comments
Comment #1
fagoThis is desired behaviour and new for 7.x-2.x. Loading variables in rules and using them in subsequent rules is not only fragile (what if the first rule hasn't fired?), moreover most user never were aware of this possibility. Instead the way to go for 7.x-2.x is to create a component + execute the component via an action and pass the new variable to the component.
And yes, we need to improve UX to ease creating a new component + adding an action to invoke it at the same time.
Comment #2
BenK commentedHi fago,
Thanks for the explanation and pointing me in the right direction. I guess I'm still a little confused about how to use components properly.
Basically, I'm trying to do something pretty simple:
1. Load the number of unread messages for message recipient (we have a working action for this).
2. Do a data comparison on the number of unread message to see if there are more than 10 unread messages.
3. If there are more than 10 messages, send recipient an email asking him to check his messages (basic mail action).
So first, I'm a little confused about which component to choose [Condition set (OR), Condition set (AND), Action set, Rule, Rule set].
Second, do I still need to have a separate rule that is executed first to load the number of unread messages?
Third, when configuring the component, would I just enter the machine name of the unread message action and choose the "Privatemsg" data type?
Fourth, I don't see a way using the data comparison condition to compare it to a number (like "10" in the example). As far as I can tell, the UI only currently allows comparing to another variable.
I plan to write this up as a FAQ for Private Message users as soon as I can determine the best way to configure this...
Thanks,
Ben Kaplan
Comment #3
berdirAh, now I understand the components :)
We got it I think, just one question. What is the difference between rule and rule set when creating a component?
Comment #4
fagoGreat you got it .. :)
>What is the difference between rule and rule set when creating a component?
A "rule set" is a set of rules, thus consists of multiple rules. A rule is a single rule.
>So first, I'm a little confused about which component to choose [Condition set (OR), Condition set (AND), Action set, Rule, Rule set].
I guess we need a good help text there.
>Fourth, I don't see a way using the data comparison condition to compare it to a number (like "10" in the example). As far as I can tell, the UI only currently allows comparing to another variable.
You should be able to switch the argument configuration mode via the button?
Comment #5
fagoadding tag
Comment #6
mitchell commented@fago: could you please evaluate the feasibility of #1495718: Add option to convert a set of conditions or actions to a component? I think that relates here.
Comment #7
mitchell commentedComment #8
mitchell commented> #4: "I guess we need a good help text there."
See #1068192: Add component dialog should explain component types.
> + adding an action to invoke it at the same time.
I don't understand this. If anyone wants feature, please open a new issue and add a reference in this issue. I'm going to mark this as fixed because I think #1495718: Add option to convert a set of conditions or actions to a component might be of a similar vane.