3

Most of the actions in Rules allow you to use tokens, but seemingly the most obvious place where this would be useful, "Set a data value," does not seem to support it. Am I missing something? It seems like it would be pretty trivial to add support for this, but I can't find in the code why, for example, the "title" field in "create a new entity" supports tokens, but "Set a data value" does not. Thanks!

1
  • Which version of Drupal and Rules do you have? I'm using drupal 7 and Rules 7.x-2.6, and when I add a new Rule, I add an "Action", then "Set a data value", then you have a data selector to choose your token. I chose "node:title". On the next page, I have the possibility to put PHP code or Replacement patterns. Maybe it's because of your view type or your condition... Did you see this line "To make entity fields appear in the data selector, you may have to use the condition 'entity has field' (or 'content is of type')." ? Or maybe it's just me confusing Replacement Patterns and tokens.
    – Matt
    Dec 20, 2013 at 9:31

1 Answer 1

2
+50

It depends on the type of the selected target data whether tokens can be used for the value or not.

For example if the target is a simple text field (e.g. node:title) then the value can be specified with tokens. On the other hand, if the selected target is for example an entity (e.g. node:field-tags:0), then token input is not possible.

When working with formatted text, it is necessary to drill down to the value column of the field. E.g. for the node body, specify node:body:value.

8
  • It's a long text field for the target field Dec 20, 2013 at 16:11
  • @NigelWaters: Could you be more specific? Perhaps provide the machine name of the target field type in question?
    – znerol
    Dec 20, 2013 at 16:15
  • It's no different than a standard body field without a summary. field name is field_description set to Full HTML Dec 20, 2013 at 16:17
  • @NigelWaters: Updated the answer with directions when working with formatted text.
    – znerol
    Dec 20, 2013 at 16:22
  • It appears that the ability to use replacement patterns return when the text field is changed to "plain text". Using "Filtered text (user selects text format)" does not work. Dec 20, 2013 at 17:17

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.