I've been struggling with sending notifications to users about State changes. I've been unable to have access to both the properties of the NODE (Title, Author, etc) and the TRANSITION (Comment, User, State Name) at the same time. I've tried using ACTIONS and RULES (Node Save Event) to send email notifications.

I've been digging into code and documentations and figured that I could solve problem by creating a rule that reacts on WORKFLOW EXECUTED TRANSITION save...

IT WORKED! I was able to use tokens from NODE and TRANSITION in my emails. Everything was perfect, then we noticed new NODES being saved were malformed. Saved with no field data. I went through watchdog and noticed that TRANSITION is saved before NODE.

I added a condition to the rule to prevent it from firing on initial save and still got the same results. I even added condition to prevent it from firing at all but still same problem. It's like the evaluation of the rule itself is breaking the node save process.

The only way we were able to get nodes to begin saving properly was to disable the rule all together.

Am I possibly just using the wrong approach. Should I not be using this event to trigger rules.

Comments

Kcannick created an issue. See original summary.

djdevin’s picture

I've confirmed this. We have the same issue and same setup. When creating a new node with a workflow, with a rule that fires on workflow transition, the node fields are not saved.

I have steps to reproduce, from a stock Drupal 7 install:

1. Create a workflow with 2 states (grant all permissions to author)
2. Assign workflow to Basic page
3. Create a new Rule that reacts on "After saving a new workflow executed transition"
4. Add one condition - Entity is of type "node" on WorkflowTransition:entity
5. Create a new page with some body text and save it
6. Edit the page after saving

Body text is empty (and any other fields, except title).

BUT:

The data *is actually saved* into the field_data_body table.

If you clear the cache, the data will come back.

This seems to be some sort of race/cache issue between workflow and rules.

johnv’s picture

Status: Active » Closed (outdated)

I guess this can be closed.

johnv’s picture

Please check the src/Event directory in version 8.x for alternatives and example code.