How to send a message notification based on a flagged node being linked via entity reference? I'm trying to figure out how to make the following work: Sending notification based on flagged node being linked via entity reference.

I have a 'News' content type and a 'Band' content type, that has a flag called 'fan'. When somebody becomes a fan, I want them to receive a notification via the Message module whenever I link the band to the content type 'News' with the News article I just created.

The content-type setup is as follows:


Node type 'News' has field:
Entity reference to content type 'Band'
The Band content type has a flag called 'fan' 
The Message type is called "user notification center" and has a field named field_mnc_recipients, which is an reference to a user(unlimited values)


How I want it to work:


when a user flags the 'band' and a new article is referenced to the band, I want to notify them with the Message module,
to make it work, I need to get the user from the flag for that band and insert it into the message field  field_mnc_recipients.


I created a Rules Component as follows:

{ "rules_message_tes3" : {
"LABEL" : "message tes3",
"PLUGIN" : "rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules" ],
"USES VARIABLES" : {
  "referencing_node" : { "label" : "referencing_node", "type" : "node" },
  "referenced_node" : { "label" : "referenced_node", "type" : "message" }
},
"IF" : [
  { "node_is_of_type" : {
      "node" : [ "referencing-node" ],
      "type" : { "value" : { "bands" : "bands" } }
    }
  },
  { "entity_is_of_type" : { "entity" : [ "referenced-node" ], "type" : "message" } },
  { "entity_has_field" : { "entity" : [ "referenced-node" ], "field" : "field_mnc_recipients" } }
],
"DO" : [
  { "LOOP" : {
      "USING" : { "list" : [ "referencing-node:flag-fan-user" ] },
      "ITEM" : { "list_item" : "Current list item" },
      "DO" : [
        { "data_set" : {
            "data" : [ "referenced-node:field-mnc-recipients" ],
            "value" : [ "referencing-node:flag-fan-user" ]
          }
        },
        { "entity_create" : {
            "USING" : {
              "type" : "message",
              "param_type" : "user_notification_center",
              "param_user" : [ "site:current-user" ]
            },
            "PROVIDE" : { "entity_created" : { "entity_created" : "Created entity" } }
          }
        }
      ]
    }
  }
]


}
}

And now I got stuck, I based the component on "Sending a message to users of a flagged node when it is referenced" which is close to what I want.
It works, after days and days it finaly works! I used this as a base line for my research: Sending a message to users of a flagged node when it is referenced

Instead of sending an e-mail within the loop, i create a new entity(action), in this case the message notification. After that i fill(set data) in the entity-created:field-mnc-recipients field with the flagging users. This is how it works :)