5

Originally posted this in the Rules issue queue ( http://drupal.org/node/1547160 ) but then saw how few posts from the last 2 weeks had any replies. Scary!

When setting a data value (text) I am unable to include a rule variable (also text) in direct input mode. I was originally trying to do this to build up a large string from fields while looping through a list of nodes. For the sake of understandability I've reduced this to the simplest possible case. The rule export is below and requires Devel module.

Note: I can perform direct assignment of one variable to another using data selection. (Unfortunately that does not satisfy my use case.) It's just direct input mode where I'm failing.

Please can someone tell me whether I should be able to do this and, if so, what I'm doing wrong?

{ "rules_example_text_inclusion" : {
    "LABEL" : "Example text inclusion",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules", "devel" ],
    "ON" : [ "node_view" ],
    "DO" : [
      { "variable_add" : {
          "USING" : { "type" : "text", "value" : "*This is the value of text_variable_1*" },
          "PROVIDE" : { "variable_added" : { "text_variable_1" : "Text variable 1" } }
        }
      },
      { "variable_add" : {
          "USING" : {
            "type" : "text",
            "value" : "*This is the initial value of text variable 2*"
          },
          "PROVIDE" : { "variable_added" : { "text_variable_2" : "Text variable 2" } }
        }
      },
      { "data_set" : {
          "data" : [ "text-variable-2" ],
          "value" : "Overwriting the value of text_variable_2:\r\n[text-variable-1]\r\n[text_variable_1]\r\n"
        }
      },
      { "devel_debug" : { "value" : [ "text-variable-2" ] } }
    ]
  }
}
3
  • Welcome to Drupal Answers. Please note that if this is a bug with Rules, it's out of scope for this site. The Rules issue queue is often overloaded but that's because it is a very popular, complicated module that causes a lot of questions. If you're stuck with a Rules issue and waiting for an answer, I would suggest trying to answer a few of those other questions in the queue. Perhaps you can help someone else, and every time you answer a question you give the Rules maintainers a bit more time to take a look at your question. Apr 25, 2012 at 15:20
  • Also, if you have already asked the question in the issue queue, please add a link to that issue queue question in your post here. (Rationale: meta.drupal.stackexchange.com/a/745/5147) Apr 25, 2012 at 15:26
  • @Patrick My (possibly feeble) search engine skills have not allowed me to determine whether this is a bug so I have assumed that I am just doing something wrong (hence support request in the issue queue). That's a very good point about helping out on Rules issues, unfortunately I am still looking for one I can answer. I did manage to answer a Rules question on this site, but obviously that's not going to help the Rules maintainers :S
    – crantok
    Apr 25, 2012 at 15:31

1 Answer 1

2

Okay, the answer is: What I was doing wrong was trying to use a feature that did not exist! However, milesw posted a patch on my d.o issue ( http://drupal.org/node/1547160 ) that totally worked for me (woo!) and that I hope will work for you too if you're looking for the same feature.

Edit: If you are looking for this feature please could you try milesw's patch and feed back on it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.