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

jmickela’s picture

Did 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.

Jibus’s picture

Same here =)

kaizerking’s picture

select delta value 0 to set new value

busla’s picture

doesn´t that only add a value to the first field collection item? What happens if you add another item with delta:1 ?

funkeyrandy’s picture

anyone ?

vadym.kononenko’s picture

I'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.

Anonymous’s picture

Issue summary: View changes

Time 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)

Anonymous’s picture

Status: Active » Needs review
Anonymous’s picture

Oh, 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)