19

I'm trying to set up a Rules Action that can change the value of a field. I created an Action Set with a data type of Node. When I go to create a Rules Action, I have access to every default Drupal node field, but no fields.

Is this simply not possible? Do I need some other module to make this work?

0

3 Answers 3

16

You first need to add a condition to check if the field exist on that node, only then it is available to the actions. There is a specific condition to do this.

1
  • 1
    Also it needs to be a ruleset in order to have access to conditions apparently.
    – Joren
    Oct 5, 2011 at 3:21
7

Using the "Entity has field" (or "content is of type") condition will make the fields become available with data selection in the Action "Set a data value".

2

Not to contradict both prior answers, but IMO they are both missing (ignoring?) a crucial part of the question, which is "...I created an Action Set...". True, part of the solution is, pretty sure, "Entity has field" (as in the answer from jcarballo). But, by design of a Rules Action Set, you cannot include any Rules Condition in it. Therefor, either of the following is needed to complete the answer to this question:

With the above in mind, you should be able to create a Rules Action like (e.g.) "Set a data value" for your field, if you also add a Rules condition Entity has field (related to the field for which you want to set a value). And make sure to add that Entity has field condition BEFORE other Rules Conditions in which you might want to refer to this field (if you have any such conditions in your rule).

That's also what is mentioned in the Rules UI, e.g. when you're adding a "data comparison" condition: somewhere it says "The data selector helps you drill down into the data available to Rules. To make entity fields appear in the data selector, you may have to use the condition 'entity has field' (or 'content is of type')".

For a video tutorial that illustrates the importance of this Entity has field condition, refer to Data types and data selection, especially what is shown between about 13:30 and 17:30 in it.

1
  • Re: that second option, as I understand it, you can only use Action Sets, not Rules Sets, as available actions in Views Bulk Operations (VBO). Apparently this is because the View is supposed to take on the burden of verifying that the entities to process are legit ones that the user wants (both by using Views Filters [regular and/or Contextual] and by checking the checkboxes of just the desired entities to process), so conditions shouldn’t be needed. But this effectively puts the key to the piggybank inside the piggybank. So Conditional Rules may be just what the doctor ordered.
    – Joel MMCC
    Aug 15, 2017 at 15:46

Your Answer

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

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