3

Using drupal 7 and the Rules module, I'm trying to "create a new entity" of type comment. What it's strange, is that although all the other fields accept tokens, "the main body text" doesn't. Tokens are considered as simple text.

Anyone experienced this and know how to solve it?

0

1 Answer 1

2

Have a look at Comment # 10 of the Rules (support) issue titled "Access and Set Comment extra fields ". It includes a Rule example that looks like so:

{ "rules_test" : { "LABEL" : "Comment bot", "PLUGIN" : "reaction rule", "REQUIRES" : [ "rules" ], "ON" : [ "node_update" ], "IF" : [ { "entity_has_field" : { "entity" : [ "node" ], "field" : "field_status" } } ], "DO" : [ { "entity_create" : { "USING" : { "type" : "comment", "param_subject" : "zzz", "param_node" : [ "node" ], "param_author" : [ "node:author" ], "param_comment_body" : { "value" : { "value" : "This text will be replaced in the next action.", "format" : "filtered_html" } } }, "PROVIDE" : { "entity_created" : { "new_comment" : "New comment" } } } }, { "data_set" : { "data" : [ "new-comment:comment-body:value" ], "value" : [ "node:field-status" ] } } ] } } 

The clue to solve your issue (= work around?) is to use that last Rules Action starting with "data_set".

3
  • 1
    Thank you for your reply! As a workaround it works! It's strange that this is not implemented by default by the Rules module. Commented Oct 20, 2016 at 7:52
  • For sure, I was thinking about ways to improve this (for example, translation support is not available, neither HTML support) but I think now it's the best answer, marked as accepted :) Commented Oct 20, 2016 at 10:30
  • @Kropot : merci for the accept. About "translation support", not sure what exactly you mean by that. But maybe you should create a new question as a followup to this one? If it makes sense, even with some link to this question also? Commented Oct 20, 2016 at 10:36

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.