How to Flag a created entity via Rules

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

Hi, Looking for help using Flag and Rules.

Once an even fires, I'd like a node to be created and for the created node to be flagged.

Currently:

 The rule properly creates the node.
 The flag can be manually toggled on the new node.

The rule does not flag the new node.

Initially I thought the data selector should be entity-created. I then attempted to fetch the entity [entity-created:type] and flag [entity-fetched:0]. Again, no love.

Any assistance on how to flag a created entity would be appreciated.

Comments

Node must be saved first

itangalo's picture

In order for this to work, you will need to have the new node properly saved before setting the flag. That is when the node gets its ID, and only then can flags be set (I assume).

To make this happen with Rules, you need (I think) a rule set – one of the components you can create. In that, first add a rule that creates the new node, and use the save entity action as well. Check the force immediate saving option, or Rules will try to be smart and wait with saving until the entire component has finished.

Then add another rule in the set, which sets the flag (also inside the rule set).

Good luck!
//Johan Falk
**
Check out NodeOne's Drupal Learning Library! 250+ screencasts and exercises, for Drupal introduction, advanced configuration, and coding. Creative Commons license!

True for Page Redirect after Create Entity action too!

ruess's picture

Thanks Itangalo!

This was so helpful in helping me determine why I couldn't redirect to a newly created entity type as well! Beautiful!

Thanks!

nonprofit's picture

Itangalo, I forgot to thank you for your kind assistance.

Greatness regarding the save

grn's picture

Greatness regarding the save Entity info :-)

BR. GrN.dk

Rules

Group organizers

Group categories

Categories

Group notifications

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