1

Not sure why this condition is ALWAYS evaluating to true. Trying to check to see if the value in a long text field has been changed.

The first field in the condition node-unchanged:field-security-audit (field type is Long Text) is always evaluating as true. The second field node-unchanged:field-security-audit-status-pubf (field type is term reference)is evaluating properly.

Any help would be greatly appreciated.

Here is the rule export:

{ "rules_security_audit_status_updated" : {
"LABEL" : "Security Audit Status Updated",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"TAGS" : [ "security" ],
"REQUIRES" : [ "rules" ],
"ON" : { "node_update--api_publishing_form" : { "bundle" : "api_publishing_form" } },
"IF" : [
  { "OR" : [
      { "NOT data_is" : {
          "data" : [ "node-unchanged:field-security-audit" ],
          "value" : "node:field-sucurity-audit"
        }
      },
      { "NOT data_is" : {
          "data" : [ "node-unchanged:field-security-audit-status-pubf" ],
          "value" : [ "node:field-security-audit-status-pubf" ]
        }
      }
    ]
  }
],
"DO" : [
  { "data_set" : {
      "data" : [ "node:field-security-audit-timestamp" ],
      "value" : [ "site:current-date" ]
    }
  },
  { "mail" : { //send mail
    }
  }
 ]
}
}
  • I updated the remainder of the rule which is to set a value and send an email. Also updated the field types. Thanks for the clarification. – dfish17 Feb 20 '18 at 18:06
0

First things first: your node:field-sucurity-audit token might contain a typo ... It could well be that you intended to use node:field-security-audit instead (see the difference?). If that is not the solution (yet), just keep reading ...

Also make sure to always (repeat: always) add an Entity has field condition BEFORE any other Rules Conditions in which you might want to refer to some field. So in your case you should add 2 such extra Rules Conditions (since you're checking the value of 2 different fields). That's also what is mentioned in the Rules UI, e.g. when you're adding a "data comparison" condition: somewhere it says:

The data selector helps you drill down into the data available to Rules. To make entity fields appear in the data selector, you may have to use the condition 'entity has field' (or 'content is of type').

For a video tutorial that illustrates the importance of this Entity has field condition, refer to Data types and data selection, especially what is shown between about 13:30 and 17:30 in it.

PS: I'm assuming this is about D7 ...

  • The field is of type long text. It's a comment field. It does not show up as a token in Entity has field. – dfish17 Feb 20 '18 at 21:19

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.