Using Rules to create a Comment with multiple fields formatted in the Main Body Text I'm trying to create a Rule that will create a comment on another post when a node is created. I would like the comment to contain a number of fields from the original post in a formatted manner. 

For example: I have a content type called "Project Status Reports" which has 3 text area fields: field_preparation, field_methods and field_outcomes and a node reference field: field_project_node.

When a Project Status Report is created, the user selects a node to associate it with (in field_project_node) and fills the 3 text areas.

I would like to create a Rule that gets triggers when a Project Status Report is created, which will then make a comment on the node referenced in field_project_node. I would like the body of the comment to look something like this:

&lt;h4&gt;Preparation&lt;/h4&gt;
&lt;p&gt;[node:field_preparation]&lt;/p&gt;
&lt;h4&gt;Methods&lt;/h4&gt;
&lt;p&gt;[node:field_methods&lt;/p&gt;
&lt;h4&gt;Outcomes&lt;/h4&gt;
&lt;p&gt;[node:field_outcomes]&lt;/p&gt;


I have created the Rule successfully and have it triggering however I am unable to work out how to fill the Main Body Text of the comment with formatted text which will do the replacements. All I can seem to do is either add static html or have it post a single field.

Is this possible? Thanks in advance
Step 1: Getting around a known comment body limitation

I think the core of your question relates to what's written in Comment # 10 of the Rules (support) issue titled "Access and Set Comment extra fields ", i.e.:


  ... param_comment_body doesn't assume any data types except 'formatted text' ...


This issue 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 rework your exported rule (as in revision 1 of your question) so that it uses that last Rules Action starting with "data_set".

Step 2: Combining 3 fields

However, since in your case you want to combine those 3 text area fields, you should also include these extra Rules Actions (prior to that Rules Action starting with "data_set"):


Add a variable (to use as your comment-body later on), say with machine name like variable_for_comment_body.
3 (similar) Rules Actions to Set a data value, for variable [variable-for-comment-body] (added in the prior Rules Action), whereas each of these 3 Rules Actions will refer to the value of each of your 3 text area fields.


For an example rule where you can see this technique at work, refer to my answer to "How to use Rules to send an eMail with a body containing all items of a field collection?" (you don't need a Rules loop though, just those 3 similar Rules Actions.

And with the above logic in place, theh value in your last Rules Action starting with "data_set" simply becomes [ "variable-for-comment-body" ].