I have a field status that when user uploads a file, is populated by a taxonomy term "uploaded". Now when an administrator downloads the file I need the status field up change to taxonomy term processing. I have tried using Rules but can't get it right.

The Rule is like so:

  • Event->content type viewed
  • Condition->User has Role of Administrator
  • and I can't set the action.

The action data is [node:field-status], Value [node:field-status:parent:1] But when I test it, it changes the status to "none". The taxonomy terms in order are: uploaded, processing, admin hold, error, closed. So shouldn't the parent:1 be processing?

Am I asking to much of Drupal 7.50, or can someone point me in the right direction?

  • I think you need to set the field's data value using direct input? in the rules action with the term id. Don't fo anything with the parent. Commented Aug 25, 2016 at 3:54
  • The problem with a direct input is, I have a field in the taxonomy that stylizes the table row with a color depending on the term used in status.
    – Steveep
    Commented Aug 30, 2016 at 22:26
  • I guess there is no way to accomplish what I need in Drupal
    – Steveep
    Commented Oct 10, 2016 at 19:42
  • There is but you shouldn't be playing with the parent:1 etc. That just means that the status field is unlimited and using :0 :1 etc means you're accessing the taxonomy term, if it's set. Use the "add to list" action if it's unlimited and direct input for your rules config. Your last comment doesn't make much sense. I don't understand how using direct input in your rules configuration would change the tables row styling. Commented Oct 11, 2016 at 2:58
  • As for your problem, you could try using the rules link module to create the download link. It would redirect to the file's url and also change the taxonomy term. That way it only changes status when the file is downloaded. Commented Oct 11, 2016 at 2:58

1 Answer 1


Question clarification

There is something in this question that I find bizarre: the requirement relates to "when an administrator downloads the file", but then the Rules Event mentioned is "content type viewed" (and combined with a Rules Condition "User has Role of Administrator").

Therefor I'm going to assume that "Content is viewed by a user who has the admin role" is an acceptable translation of "when an administrator downloads the file". With that in mind, read on about (a) what the reasons (multiple ...) are why it doesn't seem to work and (b) how to make this to work anyway ...

Mistake 1 - Use the correct token

The node:field-status is clearly a term reference field, which can, obviously, only have 1 possible value, which is one of these: uploaded, processing, admin hold, error, closed.

When you're using the Rules UI, in this case you should just use the token [node:field-status], and NOT (repeat: NOT) [node:field-status:parent:1]. That explains '... when I test it, it changes the status to "none" ...' (as in the question).

Mistake 2 - Rules Condition 'Entity has field' is missing

From the Rules Conditions mentioned (only "user has role admin"), I'm about sure that there is a crucial additional Rules Condition that you would need ALSO to make this work. I.e. you need to tell the Rules module that you want to do something with the node:field-status field. I.e. you need to add a Rules Condition of "Entity has field" (related to that node:field-status field). Even though there are variations (other Rules Conditions), this "Entity has field" is what for me always seems to work when I want to do something with a field in Rules.

Using this Rules Condition is like ringing a bell for the Rules module to prepare for that, and have Rules already go retrieve the existing data about that field, so that you can (eg) test the existing value it contains (in a subsequent Rules Condition).

Mistake 3 - Rules Event 'Content is viewed' may be too late

Whatever you want to happen (via Rules), if you're using Rules Event 'Content is viewed', that you may simply be too late: the content is already being shown, so if the Rules Conditions or satisfied, what else do you want to happen. That is what 'Content is viewed' is all about.

If you didn't want to content to be visible at all (which does not seem to be the case here though), sorry, you're too late. If you did want something to happen BEFORE showing the content, then you should have used Rules Event "Drupal is initializing". Refer to 'How to specify a Rules event like "Content is 'going to be' viewed"?' for way more details on this. And if you want the user to see the result of your Rules Action(s), a page refresh is needed for that.

Possible alternative

Here is a rule (in Rules Export format) that might possible be an acceptable alternative (solution) to answer this question, using field_demo_tags as the machine name of the term reference field and which I labeled "Demo tags" (adapt to fit your own machine name of your field before trying to import this rule):

{ "rules_update_taxonomy_term_of_a_node" : {
    "LABEL" : "Update taxonomy term of a node",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "node_view" : [] },
    "IF" : [
      { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_demo_tags" } },
      { "data_is" : { "data" : [ "node:field-demo-tags" ], "value" : "1" } },
      { "user_has_role" : {
          "account" : [ "site:current-user" ],
          "roles" : { "value" : { "3" : "3" } }
    "DO" : [
      { "drupal_message" : { "message" : "This is a node with value \u0022[node:field_demo_tags]\u0022 for field \u0022Demo tags\u0022 ..." } },
      { "data_set" : { "data" : [ "node:field-demo-tags" ], "value" : "2" } },
      { "drupal_message" : { "message" : "Be aware: the value of the \u0022Demo tags\u0022 field just got updated to [node:field_demo_tags] (refresh the page to see the updated version ...)" } }

Some more details about it:

  • Rules Event: Content is viewed
  • Rules Conditions:
    • Entity has field, for field field_demo_tags.
    • The term id of the current value of the term must be the one for uploaded (adapt this term id to fit your case).
    • Current user has role Administrator.
  • Rules Actions:
    • Show a message (to confirm we have a hit, mostly for demo/debugging purposes).
    • Do your thing, i.e. update the term id to the value of the term corresponding to processing (adapt this term id to fit your case).
    • Show a message (to confirm we did our job, and suggest a page refresh).

For short: if a node is viewed by a user who has role admin, and the node has been tagged with the term with Term Id = "1" (which could be the equivalent of uploaded in the question), then the term will be changed to the term with Term Id = "2" (which could be the equivalent of processing in the question). Additionally, an informational message will be shown similar to this:

This is a node with value "uploaded" for field "Demo tags" ... Be aware: the value of the "Demo tags" field just got updated to processing (refresh the page to see the updated version ...)

Voilà, 2 mistakes corrected, and a workaround for the 3rd mistake, which is hopefully acceptable ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.