Drupal 7 Rules: Compare Group Reference Field and fire Rule if data changed I am using a content type called "question" which has an organic group reference field (og_group_ref). 

I want to trigger an action with Rules, when the field "og_group_ref" is changed on node update.

So I have created the following rule:

{ "rules_notify_question_author" : {
"LABEL" : "Question has moved - notify user",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules" ],
"ON" : { "node_update--question" : { "bundle" : "question" } },
"IF" : [
  { "AND" : [
      { "NOT data_is" : {
          "data" : [ "node-unchanged:og-group-ref" ],
          "value" : [ "node:og-group-ref" ]
        }
      }
    ]
  },
  { "NOT data_is_empty" : { "data" : [ "node:og-group-ref" ] } }
],
"DO" : [
  { "mail" : {
      "to" : "[node:author:mail]",
      "subject" : "Some handy subject",
      "message" : "E-Mail to author",
      "from" : "[site:mail]",
      "language" : [ "" ]
    }
  },
  { "drupal_message" : { "message" : "Message text" } } } }
]


The idea is that the author of a question gets notified, when the questions was moved to another group. The logic should be like this:


  EVENT: On Node question Update
  
  CONDITION: node_unchanged:og-group-ref != node:og-group-ref AND node:og-group-ref != EMPTY
  
  ACTION: Send Mail an show a message


My problem is, that the rule fires when the content of the field og_group_ref was changed and when it was NOT changed.

I printed the compared values in the drupal message. The values are correct. But I do not know, why the rule is triggered although the field "og_group_ref" did not change.

Has anyone an idea?
I solved the problem by creating an own condition for rules using the API of the rules module.

function hook_rules_condition_info() {
  return array(
    'rules_condition_text_compare' =&gt; array(
      'label' =&gt; t('Textual comparison'), 
      'parameter' =&gt; array(
        'text1' =&gt; array(
          'label' =&gt; t('Text 1'),
          'type' =&gt; 'text',
        ), 
        'text2' =&gt; array(
          'label' =&gt; t('Text 2'),
          'type' =&gt; 'text',
        ),
      ), 
      'group' =&gt; t('Rules'),
    ),
  );
}


See hook_rules_condition_info for more details.