Was working fine with 7.x-2.9, Now Variables are undefined, even if i rename it to a new name it is still. Undefined.

Unable to get variable variablename, it is not defined.
when i rename variablename to variablename2,
Rules Error: The Data Selector variablename for the parameter parameter name is invalid.
within the Rule i change The Data selector to variablename2. and i still get the error.
Unable to get variable variablename2, it is not defined.

Comments

GOJR created an issue. See original summary.

GOJR’s picture

Status: Active » Needs review
GOJR’s picture

Priority: Normal » Critical
GOJR’s picture

Priority: Critical » Major
Matroschker’s picture

I can confirm this - with 7.x-2.9 it works with our rules, but now after the update to 7.x-2.10 we got this error in the log:

Unable to get variable assigned_products, it is not defined.

GOJR’s picture

I had to regress to 7.x-2.9 for the moment until this get fixed has i don't see how i can fix it from 7.x-2.10.

activelink’s picture

This issue appears to be caused by Views Bulk operations, rather that Rules itself. I can confirm that I had this problem, and I was in the process of setting up some new, manually triggered VBOs, for my site, when I realised that the Workflow module also had a similar problem when working with VBOs: A VBO that uses "Change workflow state of post to a new state" works, but one that uses "Change workflow state of post to next state" fails (it sets the workflow state to the same state that it's already in, and returns an "Unable to get variable variablename, it is not defined. error". It seems that the function "views_bulk_operations_action_load_id_list" in file "views_bulk_operations_views_list.inc" is returning the workflow states out of sequence, and this is causing the problem that we are seeing here in Rules.

I applied the patch from https://www.drupal.org/node/2862858#comment-12001237 and also the one from https://www.drupal.org/node/2853029#comment-11949835 - both patching the VBO module's "views_bulk_operations.rules.inc" and these appear to have eliminated this problem.

mvonfrie’s picture

Status: Needs review » Needs work

This bug is not only related to VBO. I have a custom rule action with three parameters, two integers and a node which is optional. My constellation is a node with an entity reference to an entity, and the entity can only be edited by the user via Inline Entity Form of the node edit form. Thus when creating a new entity (and a new node as well) the rule reacting on the entity creation fails with this bug. At the time of inserting the entity of course the node doesn't exist and cannot be provided to the rules action. In my situation RulesState::get($name) is not aware that the parameter is defined as optional and it should return NULL instead of throwing the exception.

TR’s picture

Status: Needs work » Postponed (maintainer needs more info)

Could someone please provide an export of a (simple) rule that demonstrates this problem? What action is this, what data type, how have you configured it, etc - all of these will be answered by the export so we don't have to guess and endlessly try different things to try to reproduce this error.

TR’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)
dzy’s picture

Status: Closed (cannot reproduce) » Active

I am using rules 7.x-2.12.

Unable to evaluate condition flag_flagged_node.
Unable to get variable comment, it is not defined.

after user save comment, i want flag this node as [he has reviewed this node] something like that.

{ "rules_flag_reviewed_node_after_user_comment" : {
    "LABEL" : "flag reviewed node after user comment",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "flag", "rules", "comment" ],
    "ON" : { "comment_insert--comment_node_enroll" : { "bundle" : "comment_node_enroll" } },
    "IF" : [
      { "NOT flag_flagged_node" : {
          "flag" : "userreviewed",
          "node" : [ "comment:node" ],
          "flagging_user" : [ "site:current-user" ]
        }
      },
      { "user_has_role" : {
          "account" : [ "site:current-user" ],
          "roles" : { "value" : { "17" : "17" } }
        }
      }
    ],
    "DO" : [
      { "flag_flagnode" : {
          "flag" : "reviewed",
          "node" : [ "comment:node" ],
          "flagging_user" : [ "site:current-user" ],
          "permission_check" : "1"
        }
      },
      { "flag_flagnode" : {
          "flag" : "userreviewed",
          "node" : [ "comment:node" ],
          "flagging_user" : [ "site:current-user" ],
          "permission_check" : "1"
        }
      }
    ]
  }
}
TR’s picture

Version: 7.x-2.10 » 7.x-2.x-dev
Priority: Major » Normal
Status: Active » Postponed (maintainer needs more info)

Please simplify this export to include only the things necessary to reproduce the error. For example, the error says: "Unable to evaluate condition flag_flagged_node." so I suspect you will still have that problem if you remove all the actions and remove your second condition. Likewise, can you write this Rule to use one of the built-in content types like article or page so we don't have to guess at what your "comment_node_enroll" content type looks like? Also, please describe how you configured the flag on the content type.

Yes, this requires you to do a little work, but without complete information we will not only have to recreate your content type and fields, but we will have to guess at how you've configured them. If we can't reproduce the error that may simply mean we just guessed wrong.

So please simplify the problem first before you export the Rule.

dzy’s picture

I tried as you suggested, but couldn't reproduce the problem using the article type. I guess this may be related to my custom permission.

I used the hook_comment_insert() and node_load() function. Maybe somewhere the return value did not pass comment successfully. I'll try again another day.

TR’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)
wutu’s picture

After update to 7.x-2.12 I have same error.

Rules:

{ "rules_auto_product_display" : {
    "LABEL" : "Auto - product display",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "TAGS" : [ "products" ],
    "REQUIRES" : [ "rules", "entity" ],
    "ON" : { "commerce_product_insert" : [] },
    "DO" : [
      { "entity_create" : {
          "USING" : {
            "type" : "node",
            "param_type" : "product_display",
            "param_title" : [ "commerce-product:title" ],
            "param_author" : [ "commerce-product:creator" ]
          },
          "PROVIDE" : { "entity_created" : { "entity_created" : "Created entity" } }
        }
      },
      { "data_set" : {
          "data" : [ "entity-created:field-product-reference" ],
          "value" : [ "commerce-product" ]
        }
      },
      { "entity_save" : { "data" : [ "entity-created" ] } }
    ]
  }
}