Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have field collection item which has 3 fields, I wanted to set 'new' values of the fields using set data rule, this thing doesn't work.
We have to manually click the add link and again save then only the values are set, Can some one guide why it is not creating(adding) values from rules set data
Comments
Comment #1
jmickelaDid you ever get anywhere with this?
I have a content type that has a multi-value field collection and I would like to be able to add new values with a rule.
Comment #2
Jibus CreditAttribution: Jibus commentedSame here =)
Comment #3
kaizerking CreditAttribution: kaizerking commentedselect delta value 0 to set new value
Comment #4
busla CreditAttribution: busla commenteddoesn´t that only add a value to the first field collection item? What happens if you add another item with delta:1 ?
Comment #5
funkeyrandy CreditAttribution: funkeyrandy commentedanyone ?
Comment #6
vadym.kononenko CreditAttribution: vadym.kononenko commentedI'm trying to use this way too. But it is not work now.
https://drupal.org/node/1822844
This patch solved my problem. But I don't known if it will fix work of the Rules with FieldCollection revision operations.
I've debugged it and allocated Rules load the HostEntity FieldCollection field without revision_id value and save it after that.
As I see it fixes just view of the FieldCollections list.
Comment #7
Anonymous (not verified) CreditAttribution: Anonymous commentedTime has past, but this seems to be possible like this:
rule:
*event - After saving node of type (any type with the field collection in it)
*condition - none
*action
1. (Loop if multiple items needs to be added)
2. Create new entity > field collection item > fill in the 'field name' and 'host entity'
-provides variable 'entity_created'
3. Set data value
-entity_created:field_(the field you wish to add content to - my case: field_left and field_right)
Comment #8
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #9
Anonymous (not verified) CreditAttribution: Anonymous commentedOh, and if you need to update existing field collection item values (as asked in the question...) this should work:
1.loop through the field collection
2.fetch entity by id (current-list-item:fiel_collection_item_id)
3. create component of type Rule and ad this to the loop as an action.
4. component parameters:
4.1. entity: field collection item (from the loop)
4.2. text (or any type of data you want to add/edit to field collection item field)
5. component condition: Data comparison > Data to compare: [current-fc-item:field-name], Data value: Field collection field name > select your field collections name.
6. component action: set data value > entity:field_example > text (or any_type_of_data_field from parameter)