Ive got a node with a file attachment field. When I save the node, my Rule when saving new content is triggered, sending out an email.

But then Drupal updates the node when it saves the attached file, triggering my second updated content rule, sending out effectively the same email.

So what I want to happen is for the email recipient go get a single email when the node is saved rather that two.

Any ideas anyone? Thanks

Comments

tonyhrx’s picture

Component: Rules Core » Rules Engine

Further to this, Drupal seems to be invoking the updated content rule even though I creating new content

See debug at 68.436 ms

0 ms "After saving new content" has been invoked.
0.105 ms Executing the rule "Quick email publish trigger" on rule set "After saving new content"
0.292 ms Condition "Created content is Quick email" evaluated to TRUE.
5.99 ms Condition "Created content's field 'field_publish' has value" evaluated to TRUE.
6.462 ms Condition "Created content's field 'field_email_group' has value" evaluated to TRUE.
7.622 ms Loaded variable "content's author"
7.677 ms Action execution: "Quick email rule set"

8.171 ms "Quick email rule set" has been invoked.
8.259 ms Executing the rule "Send to committee rule" on rule set "Quick email rule set"
8.766 ms Condition "Content's field 'field_email_group' has value" evaluated to TRUE.
19.263 ms Action execution: "Send an HTML mail to all users of a role"
62.649 ms Action execution: "Publish Content"
63.272 ms Executing the rule "Send to members rule" on rule set "Quick email rule set"
63.85 ms Condition "Content's field 'field_email_group' has value" evaluated to FALSE.
63.929 ms Evaluation of "Quick email rule set" has been finished.

64.116 ms Saved variable created content of type node.

68.436 ms "After updating existing content" has been invoked.
68.54 ms Executing the rule "Quick email un-published trigger" on rule set "After updating existing content"
68.735 ms Condition "Updated content is Quick email" evaluated to TRUE.

itangalo’s picture

Seems almost like a bug that Drupal resaves the node just because it has a file attached to it, but there is probably nothing to do about that.

To solve this problem I would probably add an additional condition somewhere – for example in the rule acting on new content – checking if there is a file attached. If so, don't send the e-mail (since it will be sent by the rule used when content is updated).

A hack, but it would probably work. Good luck!

//Johan Falk, NodeOne, Sweden
PS: I'm not maintaining the Rules module, just helping with support questions. You are welcome to ask more questions at http://groups.drupal.org/rules

itangalo’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.