Hi,

I am trying build a rule that reminds users to fill in some mandatory profile information, by checking emptyness of a Profile2 profile field. Rule is as follows

{ "rules_remind_user_to_enter_profile_inf" : {
    "LABEL" : "Remind user (individual) to enter mandatory information",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules" ],
    "ON" : [ "user_login" ],
    "IF" : [
      { "user_has_role" : { "account" : [ "account" ], "roles" : { "value" : { "4" : "4" } } } },
      { "AND" : [] },
      { "data_is_empty" : { "data" : [ "account:profile-individual-profile:field-profile-sin" ] } }
    ],
    "DO" : [
      { "redirect" : { "url" : "user\/[account:uid]\/edit?destination=dashboard" } },
      { "drupal_message" : { "message" : "Please fill in the mandatory parts of your profile (i.e. those marked with an asterisk)" } }
    ]
  }
}

Am I doing something wrong, or is this a glitch?

Thanks
Oskar

Comments

larowlan’s picture

Component: Rules Core » Rules Engine

sub

videographics’s picture

I'm seeing the same thing with a date field.

anni’s picture

Same issue here...

gafenn08’s picture

Version: 7.x-2.0-beta2 » 7.x-2.0

I am seeing this in rules 7.x-2.0 as well.

fago’s picture

Title: "Data value is empty" check always returns true for Profile2 fields » "Data value is empty" check always returns true for some fields
Version: 7.x-2.0 » 7.x-2.x-dev
Status: Active » Postponed (maintainer needs more info)

I doubt this is caused by profile2. Please report with which field type and entity type the condition has troubles for you.

@date module: Please make sure to test the latest dev version of the module.

anni’s picture

It happend with a date field and i used the actual dev version.

designcontext’s picture

Same problem with rules 7.x-2.0. I check for normal text fields in profiles.

mshepherd’s picture

Status: Postponed (maintainer needs more info) » Active

Similar to the OP, I'm using profile2.module and I'm trying to trigger an event after saving a new user.

When my plain text field is part of the profile entity, the condition Data field is empty always returns TRUE. When the same field is part of the user account, behaviour is as expected.

Matthew

succinct’s picture

Component: Rules Engine » Rules Core

I am having the same issue with a Decimal field. Here is an export of my rule:

{ "rules_has_no_non_new_rating" : {
    "LABEL" : "Has no non-new rating",
    "PLUGIN" : "and",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : { "node" : { "label" : "Node", "type" : "node" } },
    "AND" : [
      { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_rating_at_threshold" } },
      { "data_is_empty" : { "data" : [ "node:field-rating-at-threshold" ] } }
    ]
  }
}

This field has a value in it (the value was 80.00 for my test case) and the following was in the Rules log:

  • Evaluating and Has no non-new rating. [edit]
    • 0 ms Evaluating and Has no non-new rating.
    • 0.558 ms The condition entity_has_field evaluated to TRUE [edit]
    • 0.881 ms The condition data_is_empty evaluated to TRUE [edit]
    • 0.899 ms AND evaluated to TRUE.
    • 0.964 ms Finished evaluation of and Has no non-new rating.
  • 1.961 ms The condition component_rules_has_no_non_new_rating evaluated to TRUE [edit]

Why is it evaluating to TRUE when the field has a value?

succinct’s picture

After further testing, it seems that this only happens if the field had previously been set, and then unset again. Maybe a cache issue?

nerdcore’s picture

If this is a caching issue as @succinct speculated, and given that @mshepherd indicated a problem during a trigger "After saving...", maybe this related Rules issue is useful to you here.