Hi there....

I wanted to make a rule sending out an email when users untick a bolean single on/off tick field....
But the rule sends out 2 duplicate emails, can anyone figure out why it does that...

The rule looks like this

{ "rules_admin_change_to_basic_member" : {
    "LABEL" : "Admin change to basic member",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules" ],
    "ON" : [ "user_update" ],
    "IF" : [
      { "data_is" : { "data" : [ "account:field-fuldt-medlemsskab" ], "value" : 0 } },
      { "NOT data_is" : { "data" : [ "account-unchanged:field-fuldt-medlemsskab" ], "value" : 0 } }
    ],
    "DO" : [
      { "mail" : {
          "to" : "[account:mail]",
          "subject" : "TEST",
          "message" : "TESTER",
          "language" : [ "" ]
        }
      }
    ]
  }
}

Comments

acoustika’s picture

Category: support » bug

Well actually figured out itøs because I have another rule acting on updating an existing user that is checking the same field..

But I can't make a component conditional ruleset, because It seems you can't use account-unchanged in the component which is kinda weird...

It seems both rules trigger as they should but the other rule I have checing the same field but does other actions also trigger this rules action a second time, and doing sm weight to the 2 rules doen't help

acoustika’s picture

Title: Rule sends out duplicate mail » One rule triggers another rules action

Well I managed to make a work around doing some other checks....

But it seems like if several rules make a data comparisson on the same field they can trigger eachothers action..... that seems to me to be kind of a bug...

jkaine’s picture

Component: Rules Engine » Rules Core

Same exact problem.

jkaine’s picture

And here's the workaround I came up with:

  1. For each of my content types that can trigger an email, I created a boolean field called "hidden_mail_sent"
  2. In my rule that sends the email, I check the "hidden_mail_sent" value. The value has to be 0 for the mail to be sent.
  3. I then added an action that comes right after I've sent the email. This action sets "hidden_mail_sent" to 1. This way, when the rule runs again it'll be stopped at the check on "hidden_mail_sent" (see item 2).
  4. To hide the field from the form display (to make it hidden), I used hook_form_formID_alter to set the access to 0. This is preferred, but if you aren't up for writing your own module, you can always hide the field using CSS (display: none).
  5. If you need to use the same node to trigger additional email at later points, you'll need to write a rule that will reset "hidden_mail_sent" to 0-- based on whatever criteria meets your functionality.

Not necessarily an elegant solution, but quick and dirty and effective.

entropea’s picture

Version: 7.x-2.x-dev » 7.x-2.2
Priority: Normal » Major

Having the same issue in Rules 7.x-2.2 with Drupal 7.14.

Is there a resolution to this other than creating a monstrosity of patchwork rules?

Ideally this should be fixed in the code rather than worked around.

Can we at least get it assigned to someone to investigate?

This issue is coming up to it's first anniversary! ;)

ericwongcm’s picture

Version: 7.x-2.2 » 7.x-2.9
Issue summary: View changes

This bug/feature still exists in the latest version of rules..

What I have done is I have created two rules that uses the same triggers and check the same conditions.
Rule 1 creates a comment entity when the specific node type is created or updated.
Rule 2 sets a data value of the node when the specific node type is created or updated.

If I have these two rules active, I will end up having two comment entity created instead of 1.

The reason I have these two rules is because the final rule for both actions will have slightly different conditions, so I can't have use a single rule.

kellyimagined’s picture

Is there a plan for this to be fixed? This issue is a big bummer.

arruk’s picture

It seems that 6 years later there still isn't an elegant solution for this.

The proposed workarounds for this won't work in every case. Say, for example, you want an email sent to users who want updates when content changes. Any flag added to the node itself would prevent subsequent update notifications. There needs to be a mechanism build into Rules itself to identify when the triggering event was initiated by another rule and a condition to allow that event to be ignored. The lack of this filtering seems like a rather large design flaw.

tr’s picture