3

I have a cck content type with a multi value reference field. Using rules, I am trying to populate these reference fields when users create a different content type (for example an event and I want to keep adding user references for people that view the event -- this is an example.)

My issue right now is that I can fetch the entity to set the user reference (using a loop of users), but I can only set the first field. How do I move to the next field of the fetched entity and set it to the next user in the loop list?

I imagined that as long as I was in the loop, for each item in the loop, a set data value on the reference field would move to the next field but it simply overwrites the first one.

I see that the particular reference field I'm trying to set values for is an array (fetched-entity:field-blah:0 etc). Since I cannot pick for example item [0], I thought fetched-entity:field-blah without the delta would keep shifting to the next. It does not.

I'm thinking there is a way for me to loop through the deltas in the fetched entity as I loop through the list?

Any help appreciated.

2
  1. Install next modules:
  2. Create a rule for "Content is viewed".
  3. Set conditions , like "content is type"
  4. Create a loop and set its name, in the data selector choose the field(not the deltas) like [node:field-alumnos-curso]
  5. Create an action inside the loop(do not "set data value"), just select "add item to the list" and the value will be the list name or loop name.
  6. Remember create a action "Save an entity".
  • I do not see how this would solve my issue. At most, this would add an item to a list. I do not see how this would update my reference fields. – andrew Nov 3 '12 at 6:59
  • 1
    Choosing 'add item to list' successfully added an entity reference to a multi value field for me. You can also use 'remove item from a list' in order to remove an entity reference. – littledynamo Dec 11 '13 at 12:58
  • This is clearly a wrong answer to a question that has no other google references. Sorry to revive a very much dead post, but this is something that rules SHOULD be able to handle. Let's figure out how! – John Millnik Jun 27 '15 at 5:25
0

Its long since the question asked. Currently this can be done very easily.

  1. Load a list of entity objects. I used a VBO View.
  2. Set a data value. Parameter: Data: [node:field-your-user-ref-field], Value: [entity-list-you-loaded]
  3. Save the entity

Its as simple as this. I am using this very successfully.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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