Adding data value inside a loop

Events happening in the community are now at Drupal community events on www.drupal.org.
BrightBold's picture

I'm surprised I cant' find this documented anywhere, so I'm hoping someone here can point me in the right direction. I'm trying to set up functionality using OG and Rules where a project manager can close out a group at the end of a project, and as a result new fields would be revealed on the group content and different Views would show on the Group page. I was thinking to do this, I'd want the group content nodes to inherit the "closed" status when the project group is marked closed.

So I created the following rule:

Event:
After updating existing content

Conditions:
Content is of type: Group /* an organic groups group */
Entity has field: field_group_status
Text Comparison: node:field-group-status contains "closed"

Actions:
Get group content from a group
Loop: here's where I'm stuck

Then, what I want to do is loop through the list items (group content nodes) and set the value of the field_group_status field (a shared field, same as the one on the parent group) to also be Closed. However, I can't figure out how to get Rules to load that field, since there are no conditions available within the loop.

How can I do this? Alternatively, if it's not possible, is there a better solution I'm not thinking of?

Comments

You'll need a component

itangalo's picture

As you write, you will need a condition inside the loop to change field values for group content. The way to do this right now is to create a component (Rule), where you add the necessary condition and then the action to change the field value.

From the original reaction rule, you call this component from within the loop.

Kind of kludgy, but it works. If you have a lot of group content, though, you might run out of memory. :-/
Good luck!
//Johan Falk, Sweden

Thanks!

BrightBold's picture

So apparently I had totally ignored the existence of Components, and I watched your loop screencasts but skipped components. Oops. This works perfectly, thanks.

Thanks Itangalo , that helped

sinasalek's picture

Thanks Itangalo , that helped

Rules

Group organizers

Group categories

Categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: