Most of the actions 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!

Comments

breaklaw’s picture

Is this really a feature request? I can't believe that there isn't a way to do this? Anyone have a link to some documentation?

pixelsweatshop’s picture

I just came across this as well and was surprised. Tokens are pretty much available everywhere else in rules but for some reason it is missing here. Since this issue is just about 2 years old and there are 5 other people following this issue, maybe someone figured this out? Maybe a workaround?

RedEight’s picture

Issue summary: View changes

Ran into this issue today. My use case is as follows: I'm trying to calculate the numbers of days an item won't be in stock based on two date fields, pickup and return. The date fields contain time which causes issues with the basic method of converting to timestamp, finding the difference, dividing by 86400, adding 1, and converting to integer. The problem would be easily avoided if I could use token replacement in Set a data value. I would set each date field to [date:value:custom:Y-m-d] which would remove the time and fix my issue... unfortunately tokens do not work in Set a data value for some unknown reason. Any help would be greatly appreciated.

catapipper’s picture

Running into this issue often and having to do some very convoluted workaround to make it work. My use case is that I need to send data into a ticket system for others to work on issues. Since it is more of a forwarding kinda thing I need to have access to the variables in the nodes so that I can pass this information on.

Any help would be greatly appreciated!

TR’s picture

Status: Active » Closed (works as designed)

Tokens provide TEXT strings. If the data value you are trying to set is TEXT, then yes you can use tokens to set that text in a "Set a data value" action. Tokens work anywhere where you need to supply a text string.

If the data value you are trying to set is NOT text, then a token will not be able to supply the needed data type directly.

If you have a text token but you need an integer, for example, then you can use the "Convert data type" action to change your token into an integer, which is then available for use in subsequent "Set a data value" actions.