After updating a profile, i want to compare the new value and old value of one field then show message if the two values are differents

profile2-unchanged:user:profile-main:field-profile2 vs profile2:user:profile-main:field-profile2

When saving the form, It seems that i always get a message even the field value doesn't change.

Events : After updating existing profile
Conditions : Data comparison equals: yes (condition used only for testing)
Actions : Show message

Comments

radoo’s picture

Issue summary: View changes

events conditions actions

radoo’s picture

Issue summary: View changes

doesn't

mitchell’s picture

Component: Rules Engine » Documentation
Assigned: Unassigned » mitchell
Priority: Critical » Normal
Status: Active » Postponed
Issue tags: -rules

If you're comparing the entered data, then you need 'text comparison', not 'data comparison'. It's kinda confusing, so assigning myself to update that in the docs, or something later on.

mitchell’s picture

Issue summary: View changes

equals yes

kattia’s picture

Issue summary: View changes

I have the same issue, does anyone have a solution?

neorg’s picture

Pffff.... It took me tree days to find out what the problem is and how to deal with it.

If I drill down to the field by using the Data Selector the Data Compare fails.
If I use the direct input method and fill in the right field the Data Compare succeeds.

Some notes:

  • The problem does not occur in nodes
  • The problem does not occur in Actions. You can use the Data selector method in the Actions without any problem. (This made it so hard to solve because I saw, in the by Actions generated message, the correct unchanged and save field values)

This is a part of the rule while using the Data Selector to get to the field "profile2-unchanged:user:profile-outlet:field-shopname"

This method fails!!

{ "rules_send email" : {
    "LABEL" : "Send email if a Profile2 values is changed",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "mimemail", "profile2" ],
    "ON" : { "profile2_update" : [] },
    "IF" : [
      { "entity_has_field" : {
          "entity" : [ "profile2:user:profile-outlet" ],
          "field" : "field_shopname"
        }
      },
      { "NOT data_is" : {
          "data" : [ "profile2:user:profile-outlet:field-shopname" ],
          "value" : [ "profile2-unchanged:user:profile-outlet:field-shopname" ]
        }
      }
    ],
    "DO" : [
      { "mimemail" : {
      etc..... etc......

This is part of the rule export when I use de Direct input method and I past the field [profile2-unchanged:field-shopname] directly in the Data Value field

This method works!!

{ "rules_send email" : {
    "LABEL" : "Send email if a Profile2 values is changed",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "mimemail", "profile2" ],
    "ON" : { "profile2_update" : [] },
    "IF" : [
      { "entity_has_field" : {
          "entity" : [ "profile2:user:profile-outlet" ],
          "field" : "field_shopname"
        }
      },
      { "NOT data_is" : {
          "data" : [ "profile2:user:profile-outlet:field-shopname" ],
          "value" : "[profile2-unchanged:field-shopname]"
        }
      }
    ],
    "DO" : [
      { "mimemail" : {
      etc..... etc......

screenshot 1

I am happy that I can finally can use rules now with this workaround, but I still think this is a bug in Profiles2

Stephan Barrett’s picture

neorg, I've not been able to get this to work for me based on your method above. Anyone else have any luck here?

tr’s picture

Issue tags: -data comparison

@mitchell - did you ever write up that documentation? Still have plans to do that?

tr’s picture

Version: 7.x-2.1 » 7.x-2.x-dev

@mitchell - did you ever write up that documentation? Still have plans to do that?

tr’s picture

Assigned: mitchell » Unassigned
Category: Bug report » Task
Issue tags: +Novice

Not a bug, but still needs to be documented.