Last updated January 29, 2012. Created by Itangalo on October 5, 2011.
Edited by acrazyanimal. Log in to edit this page.
Rules has a pluggable system for data input – by default the direct input and data selection interfaces are available.
The data selection input method allows you to drill down into the data available to Rules, in that particular context. One important benefit from data selection is the ability to explore chained variables – for example node:author:… will show you data for a node's author, without the author's user object being explicitly loaded into Rules.
Note:
- If selecting an item ending with ':' you can access data inside that object, creating chains of related data.
- Modules like References and Entity Reference will provide connections between entities, such as
user:field_node_reference:nid. - Entity fields will only be available if you have used a condition to expose them or they are automatically exposed for that particular rule. By default their basic entity type properties should be exposed, but if you need access to a particular field then you can use the "entity has field" condition. If you need to access more then one of the entity's fields then you should use a "data comparison" condition against the entity's type property. Most of the time this is simply
some-entity:typein the data select widget. If any fields are common to all bundles of the relevant type, you can also use a 'entity is of type' condition to expose those fields without having to get too specific. This can be advantageous in a situation where you want to set a field on an entity of a particular entity type, but the entity may be one of any number of bundle types. For example, if I was a rental company and had a vehicle 'entity type' and several bundles like 'car', 'truck', 'snowmobile', etc that all had the common field/property 'mileage'. I could make a rule to generically set the mileage value in my tracking system without having to know what type of vehicle was returned. - If you are expected to provide data of a certain type, the data selector will only list data end points matching these requirements.
- You can use all chains of data found with the data selector as tokens in direct input mode. For example, you can use [user:field_node_reference:nid] as a token representing the node ID of a referenced node.