3

Trying to get an mail-update when a tag is selected (if a node is inserted or updated).

The debug shows that 'till the second condition, everything is working fine. The second condition should be comparing if tid = 22 is selected. And i can't get this working ..

The name of the vocabulary is 'zichtbaarheid' (dutch for visibility).

{ "rules_vinkje_k_n_mail" : {
    "LABEL" : "Vinkje K\u0026N \u003E mail",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "node_insert" : [], "node_update" : [] },
    "IF" : [
      { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_zichtbaarheid" } },
      { "data_is" : {
          "data" : [ "node:field-zichtbaarheid" ],
          "value" : { "value" : { "22" : "22" } }
        }
      }
    ],
    "DO" : [
      { "mail" : {
          "to" : "\[email protected]\u003E",
          "subject" : "[node:title]",
          "message" : "[site:current-date]\r\n\r\n[node:body]",
          "language" : [ "" ]
        }
      }
    ]
  }
}

The debug shows

...
10.619 ms The condition entity_has_field evaluated to TRUE [edit]
11.293 ms The condition data_is evaluated to FALSE [edit]
...

=== EDIT ===

The correct config is as following. Events: after saving new content & after updating

  1. First condition (to 'load' the terms): [entity has field] > in Data selector [node] & in Field the correct vocabulary
  2. Second condition: [List contains items] > Data selector: node:[fieldname]. In next screen, switch to [direct input mode]. Terms should be visible in a dropdown-menu. Choose the right value

And the export is (you should alter some settings, like the name):

{ "rules_twee_vinkje_k_n_mail" : {
    "LABEL" : "TWEE Vinkje K\u0026N \u003E mail",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "node_insert" : [], "node_update" : [] },
    "IF" : [
      { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_zichtbaarheid" } },
      { "list_contains" : { "list" : [ "node:field-zichtbaarheid" ], "item" : "22" } }
    ],
    "DO" : [
      { "mail" : {
          "to" : "\[email protected]\u003E",
          "subject" : "[node:title]",
          "message" : "[site:current-date]\r\n\r\n[node:body]",
          "language" : [ "" ]
        }
      }
    ]
  }
}

(replace node:field-zichtbaarheid with your term-name, like field-tags)

And, as bonus to prevent recursion: I've added the term 'mail send' in the vocabulary. This term is hidden, but updated with an action. When firing the rule, the second condition is now to check if the term 'mail send' is checked or not. If checked, the output is false and the rule is not further executed.

0

1 Answer 1

1

I see 2 possible reasons that may cause your problem:

  1. Maybe it's a data type conversion issue. You may be more lucky to get that 2nd condition to work if you'd use a text comparison (= "text_matches") instead of a data comparison (= "data_is").
  2. Maybe your zichtbaarheids-field is a multi value field?

To further investigate this, just add a "Display a message" (within System) as your very first Rules Action, to display the actual value (using an appropriate token for your field), after you temporary remove that 2nd rules condition (to ensure the Rules Actions are performed). If that doesn't help either, you may also want to (temporary) enable the Devel module, so that you can (temporary) add a Rules Action like "Display a value".

2
  • Ah thanks, i'm one step further. Displaying a message shows | tag1, tag2, tag3 |. It's in this case tag3. Didn't realised that it's multi value. Next step is to work with multi values
    – MatthijsG
    Oct 9, 2016 at 13:34
  • Found it: i used Data Comparison, but apparently is that for individual values. So i used the condition [List contains item] value [term]. And it's working .. I put the correct export in a new comment, for other people.
    – MatthijsG
    Oct 9, 2016 at 13:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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