0

I have one content type with a multi-value field collection entity on it.

On the event that this content type is flagged I would like to fire a rule that will create a new piece of content and copy all of the field collection lines to the same field collection type on the new content type.

The rule I have included bellow fires and creates the new content however the field collection is not copied.

{ "rules_generate_pal" : {
"LABEL" : "Generate PAL",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules", "flag" ],
"ON" : [ "flag_flagged_generate_pal" ],
"IF" : [
  { "entity_has_field" : {
      "entity" : [ "flagged-node" ],
      "field" : "field_project_personnel_needed"
    }
  }
],
"DO" : [
  { "entity_create" : {
      "USING" : {
        "type" : "node",
        "param_type" : "project_activity_log",
        "param_title" : "[site:current-date]",
        "param_author" : [ "flagging-user" ]
      },
      "PROVIDE" : { "entity_created" : { "entity_created_pal" : "Created PAL" } }
    }
  },
  { "drupal_message" : { "message" : "BOOM!" } },
  { "LOOP" : {
      "USING" : { "list" : [ "flagged-node:field-project-personnel-needed" ] },
      "ITEM" : { "list_item" : "Current list item" },
      "DO" : [
        { "list_add" : {
            "list" : [ "entity-created-pal:field-project-personnel-needed" ],
            "item" : [ "flagged-node:field-project-personnel-needed:0" ]
          }
        }
      ]
    }
  }
]

} }

2 Answers 2

0

I have used the "set data value" action in Rules to make one field collection equal another field collection. It just dumps the whole field collection in at once, so you don't have to loop through each item one at a time.

1
  • That would work in the case I mentioned above along with my answer to first create the new field collection entity first. I have also found that you can use values from elsewhere to populate the field collection once it is created. Thanks for your help. Commented Apr 3, 2013 at 16:03
0

Okay so I figured it out. On the new field collection item you need to first add the action to create a new entity of the type of field collection and then the specific field collection. Then you can add to the fields on that newly created field collection.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.