How to loop through a dynamic taxonomy vocabulary and if term is chosen, do an action? My problem is as follows:


I have a taxonomy vocabulary with terms, which are changing from time to time.
I have two node types --> type 1 and type 2
Type 1  has a taxonomy term reference field
Type 2 has an entity reference field which can be prepopulated with the module "entity reference prepopulate"


If I create a new node of node type type 1 then a rule should check which terms are selected and create a new node of type 2 for each selected term automatically. 

The entity reference field of the new type 2 node should be prepopulated with a reference back to the original type 1 node. 

Because the terms of the vocabulary are changing, the check up by the rule should be IMHO dynamic.

Dummy-Code:

If a new node of node type 1 is saved,then check which taxonomy terms are selected.

for each selected term:


create a new node of type 2
and prepopulate the entity reference field of node type 2 with the value of node type 1.


I tried it with the Conditional Rules module, but there seems no for..each control loop available.

How can I solve my problem?
If a new node of node type 1 is saved,


= Rules Event: After saving content, of type "type 1".


  then check which taxonomy terms are selected.


= Rules Action: Create a Rules loop, which iterates over each of the selected taxonomy terms, assume you use a name for each list item like "selected_term".


  for each selected term:


= Rules Action (which is part of the loop), in which you perform a "Rules Component", and which uses as parameter the "selected_term".


  
  create a new node of type 2
  


= 1st Rules Action performed as part of the Rules Component, which is to "Create an entity" (a node of "type 2").


  
  and prepopulate the entity reference field of node type 2 with the value of node type 1.
  


= 2nd Rules Action performed as part of the Rules Component, which is to "set a data value", for the entity reference field, as part of the entity (node) that got created in the previous Rules Action, and followed by a Rules Action to "save the entity".

Refer to the List and loops video for more details about processing lists and loops via Rules.

Note: no need for the Conditional Rules module ...