Available tokens
First, let us define some terms.
Rules uses variables that are passed from events to conditions to actions as part of the rule context. These variables may be simple values, such as strings or integers, or may be complex data structures like nodes and entities.
When these variables are used in direct input mode bracketed by {{ and }}, we refer to them as tokens. Rules will replace any tokens it encounters with the value of the variable. Thus, tokens are a powerful and convenient way of incorporating variable values into your conditions and actions.
The tokens that are available for you to use depends on the available context variables. Because context variables are provided by events (and sometimes by other conditions and actions that you have added), not all tokens are available at all times. If you really need a token you don't have access to, you may add an 'Add variable' action to your Rule to bring a piece of data into the context and make it available as a token.
There are also some Global context variables - these are always available for use.
The easiest way to find out which variables are in the context and available for use in tokens is to switch to the Data selector. The Data selector is a JavaScript-enabled selection widget which will dynamically display the available context variables and allow you to drill-down into complex data types to extract parts of the available data.
For example, if the node context variable is available to you, the Data selector will show this at the top level. A node is a complex data type; it holds other data such as a title, a body, an author, a creation date, and many others. You can access each of these pieces of the node by first typing a '.' after node in the Data selector. The Data selector will then show you the available pieces, node.title, node.body, node.uid, node.created, etc. Typing a '.' again will show you the sub-parts of these pieces, if any.
You may use the Data selector in this manner to construct the text you will need for the token. But remember, you can only use these tokens in Direct input mode. A token for the node title would then be written {{ node.title.value }}, which you could use in the Direct input mode.
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion