I have a component rule that receives a node, fetches all comments from that node, then inside a loop for each one of them I trigger another rule sub-component.
This sub-component receives a comment (logically) and sets a data value for the comment if the conditions are met...
If I execute the sub-component individually on a given comment it works correctly.
However, executing the global rule component, providing the Node ID and letting it call the sub-components in a loop, then the data value is not set for any comment.
Help !

Comments

nicolas bouteille’s picture

Title: Cannot set data value inside loop » Cannot set data value from component called inside loop
nicolas bouteille’s picture

Priority: Normal » Major

The field I am trying to set is an integers list but I have also tried to edit the comment's core mail field it does not work either.
I have tried to set the mail field from inside the sub-component, but also directly inside the loop without calling a component.
I thought that maybe it was because the field was not set already but even non-empty fields will not be set to a different value, if sub-component is called by the loop.
I have tried to "Save (the comment) entity" with force = TRUE, inside the sub-component + inside the loop after sub-component is called.

nicolas bouteille’s picture

Title: Cannot set data value from component called inside loop » Cannot set data value inside loop
nicolas bouteille’s picture

Issue summary: View changes
nicolas bouteille’s picture

Alright, here is a basic example that anyone should be able to import:
Please make some comments on a node, execute the component with the node id and then check if the mail field is equal to test@test.com for all comments.
This does not work for me.

{ "rules_test_set_data_value_inside_loop" : {
    "LABEL" : "Test set data value inside loop",
    "PLUGIN" : "rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "USES VARIABLES" : { "node" : { "label" : "Node", "type" : "node" } },
    "DO" : [
      { "entity_query" : {
          "USING" : {
            "type" : "comment",
            "property" : "node",
            "value" : [ "node" ],
            "limit" : "100"
          },
          "PROVIDE" : { "entity_fetched" : { "comments" : "Comments" } }
        }
      },
      { "LOOP" : {
          "USING" : { "list" : [ "comments" ] },
          "ITEM" : { "comment" : "Comment" },
          "DO" : [
            { "data_set" : { "data" : [ "comment:mail" ], "value" : "test@test.com" } }
          ]
        }
      }
    ]
  }
}
zullum’s picture

This is still an issue. Has anyone had any luck in fixing this?