Using Entity Reference in Rules

This screencast shows how you can access entity reference data in Rules, to have cool things happen. This screencast covers:

  • How to make entity reference fields known to Rules, by adding the "entity has field" condition. (Just as with other fields.)
  • How to access data from the referenced entities.
  • How to loop through multiple-value references.
  • How to use the action "fetch entity by property" to load all nodes with a particular reference value. (Just as with other fields.)
  • That all nodes built with a view mode constitutes the event "content is being viewed" in Rules. Good to know!
  • That the data is automatically accessible to Rules, if it is described to Entity API – no extra coding necessary. (Just as with other fields.)

It is not demonstrated in the screencast, but you can – just as with other fields – use the "set a data value" to change the value of a entity reference field.

By Johan Falk; Usage Attribution-Noncommercial-Share Alike 3.0