1

I am having trouble setting up a rule to email a specific user referenced by a node. The structure I am trying to set up is:

When node of type A is updated, and satisfies certain criteria, the user referenced by node of type B, which is referenced by the original node of type A, should receive an email.

Below is the error log:

0 ms Reacting on event After updating existing content.
13.753 ms Evaluating conditions of rule Released Email. [edit]
15.155 ms The condition entity_has_field evaluated to TRUE [edit]
19.279 ms The condition entity_has_field evaluated to TRUE [edit]
19.535 ms The condition entity_has_field evaluated to TRUE [edit]
26.27 ms The condition data_is evaluated to TRUE [edit]
26.288 ms AND evaluated to TRUE.
" Rule Released Email (Maintenance Log) fires. [edit]
0 ms Rule Released Email (Maintenance Log) fires.
47.438 ms Unable to get the data value for the variable or parameter to. Error: Unable to get the data property mail as the parent data structure is not set.
48.391 ms Unable to evaluate action mail. [edit]
48.472 ms Rule Released Email (Maintenance Log) has fired.

And this is what the condition structure looks like:

Entity has field
Parameter: Entity: [node], Field: <referenced node>

Entity has field
Parameter: Entity: [node:<referenced node>], Field: <referenced user>


Data comparison
Parameter: Data to compare: [node:field-status:name], Data value: <desired value>

Export:

{ "released_email_maintenance_log" : {
    "LABEL" : "Released Email (Maintenance Log)",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : {
      "node_insert--maintenance_interval" : { "bundle" : "maintenance_interval" },
      "node_update--maintenance_interval" : { "bundle" : "maintenance_interval" }
    },
    "IF" : [
      { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_project" } },
      { "entity_has_field" : { "entity" : [ "node:field-project" ], "field" : "field_pm" } },
      { "entity_has_field" : { "entity" : [ "node:field-project" ], "field" : "field_client" } },
      { "data_is" : { "data" : [ "node:field-status:name" ], "value" : "Released" } }
    ],
    "DO" : [
      { "mail" : {
          "to" : [ "node:field_project:field_pm:mail" ],
          "subject" : "[node:field-project] is [node:field-status]",
          "message" : "[node:field-project:0:field-client:title] maintenance updates are ready for your review here: [node:field_testing_url]\r\nFor more information, visit [node:url].",
          "language" : [ "" ]
        }
      }
    ]
  }
}

Based on the answer below, here is an updated export of the rule in question:

{ "released_email_maintenance_log" : {
    "LABEL" : "Released Email (Maintenance Log)",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : {
      "node_insert--maintenance_interval" : { "bundle" : "maintenance_interval" },
      "node_update--maintenance_interval" : { "bundle" : "maintenance_interval" }
    },
    "IF" : [
      { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_project" } },
      { "entity_has_field" : { "entity" : [ "node:field-project" ], "field" : "field_pm" } },
      { "entity_has_field" : { "entity" : [ "node:field-project" ], "field" : "field_client" } },
      { "data_is" : { "data" : [ "node:field-status:name" ], "value" : "Released" } }
    ],
    "DO" : [
      { "entity_fetch" : {
          "USING" : { "type" : "user", "id" : [ "node:field-project:field-pm:uid" ] },
          "PROVIDE" : { "entity_fetched" : { "user_fetched" : "Fetched user" } }
        }
      },
      { "mail" : {
          "to" : [ "user-fetched:mail" ],
          "subject" : "[node:field-project] is [node:field-status]",
          "message" : "[node:field-project:field-client:title] maintenance updates are ready for your review here: [node:field_testing_url]\r\nFor more information, visit [node:url].",
          "language" : [ "" ]
        }
      }
    ]
  }
}

And the error this new configuration produces:

0 ms Rule Released Email (Maintenance Log) fires.
3.423 ms Unable to get the data value for the variable or parameter id. Error: Unable to get the data property uid as the parent data structure is not set.
5.291 ms Unable to evaluate action entity_fetch. [edit]
6.352 ms Unable to get variable user_fetched, it is not defined.
7.117 ms Unable to evaluate action mail. [edit]
7.177 ms Rule Released Email (Maintenance Log) has fired.
  • Please include an export of your rule in your question also. FYI: something seems wrong in any of your Rules Actions, but you didn't show anything about what those rules actions actually look like. – Pierre.Vriens Feb 21 '17 at 5:49
  • Sure @Pierre.Vriens, I';ve included an export above. – Jillian Hoenig Feb 21 '17 at 14:20
  • Making progress (understanding the problem, is part of the answer, right?). Check my answer to see if you can get it to work like that. If not, then please rephrase the first 2 phrases of your question, by using the machine names of your actual content types and field names (so that they match what is shown in the exported rule). – Pierre.Vriens Feb 21 '17 at 14:52
0

The crucial error message in your error log is the one like "Unable to get the data value for the variable or parameter to". The way I read that is like "sorry, you want me to send an eMail to some eMail ID, but I'm missing its value".

It seems like you could get it to work by inserting a (1st) Rules Action (before the Rules Action you already have) like "Fetch entity by ID", to go get the relevant data of the referenced user. Whereas you use the value indicated by the user that is referenced.

If you then store the fetched user data in (eg) user_fetched, you should be able to use user_fetched:mail as the token in the "To" of the eMail you want to send.

  • Thanks for your reply! Could you elaborate a little on how to go about adding the Rules Action you've described?) I've added a Rules Action with Entity type "User" and set the Identifier to the desired user's uid, but the action doesn't evaluate... – Jillian Hoenig Feb 21 '17 at 21:18
  • @JillianHoenig can you add an update to he end of your question that includes an export of your updated rule, preceeded by something like "based on the suggestion in the answer, this is my updated rule ..."? – Pierre.Vriens Feb 21 '17 at 21:21
  • You got it Pierre – Jillian Hoenig Feb 21 '17 at 21:27
  • @JillianHoenig ok, making progress ... now you need to replace the "to" in your action to send an email with user:fetched:mail (i guess that's the token you'll be able to select in the rules ui, can you verify?) – Pierre.Vriens Feb 21 '17 at 21:41
  • 1
    @JillianHoenig Niall has a valid (interesting) point: we may not need that "fetch entity by id" at all. So remove that again, and also remove the ":mail" part in the token you're using in the "to" field of your eMail (1st rule!). If that doesn't help, please improve your question to explain how that field_pm is actually defined (to show all the details about how you configured that field in your content type). If you still can't get it to work, add some "Display a message" actions to print the values of those fields that Niall suggested in his 1st comment. PS to Niall: merci! – Pierre.Vriens Feb 22 '17 at 20:48

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.