I tried to concisely explain what I am looking to accomplish in the subject, but will go into more details here. I think I'm really close but my Google-fu is failing me.
My question: How can I use the role reference field coming through field_responsible_team in a dynamic fashion opposed to the static fashion I've solved for currently?
Current Setup:
Content Type: Question
-- Taxonomy: Category (attached to Question content type)
---- Taxonomy Field: Responsible Team (user role) / (attached to Category taxonomy)
Example Question node:
Node Type: Question
Category: Training
Responsible Team: Learning & Development
{ "rules_XYZ" : {
"LABEL" : "XYZ",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules" ],
"ON" : { "node_insert--question" : { "bundle" : "question" } },
"IF" : [
{ "entity_has_field" : { "entity" : [ "node" ], "field" : "field_category" } },
{ "AND" : [] },
{ "entity_has_field" : {
"entity" : [ "node:field-category" ],
"field" : "field_responsible_team"
}
}
],
"DO" : [
{ "mail_to_users_of_role" : {
"roles" : { "value" : { "4" : "4" } },
"subject" : "XYZ [node:workbench-access-sections]",
"message" : "XYZ"
}
}
]
}
}
I got excited when this worked, but realized I had limited this to just users of role 4.
Preferred solution: Dynamically pull in the role from the new node created and use that for the role selection in the "mail_to_users_of_role" function. I would've thought I could've used the "node:field-category:field-responsible-team" data selector, but it's telling me that "The data type of the configured argument does not match the parameter's roles requirement." I'm using the Role Reference module.
Secondary solution (solved - see below): Create one rule for each of the roles and specify the categories within the rule set (not ideal).
{ "rules_XYZ" : {
"LABEL" : "XYZ",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules" ],
"ON" : { "node_insert--question" : { "bundle" : "question" } },
"IF" : [
{ "entity_has_field" : {
"entity" : [ "node:field-category" ],
"field" : "field_responsible_team"
}
},
{ "AND" : [] },
{ "data_is" : {
"data" : [ "node:field-category:field-responsible-team" ],
"value" : "4"
}
}
],
"DO" : [
{ "mail_to_users_of_role" : {
"roles" : { "value" : { "4" : "4" } },
"subject" : "XYZ",
"message" : "XYZ"
}
}
]
}
}