Checking the Workbench Moderation State with Rules
Tags: Drupal, Workbench Moderation, Rules.
Setting up Rules to trigger when a moderation state is changed was not working as expected. I was trying to check the condition for Node: "Content's current moderation state" and "Content's previous moderation state."I want to send an email to certain users when content is moved from Draft to Needs Review. Using an event trigger of "After moderation transition," I need to check when the previous moderation state is Draft and the current is Needs Review. Which makes sense in theory but after sporadic results and more testing, it seems that the content's current and previous moderation states may be comparing revisions. I will have to do more testing and digging through code to see exactly what is happening.
I just want to know what the value was before and after the state change.
To do this, you need to use the Data Comparison condition. There will be selectors available for previous-state and new-state. Compare these to the machine names for your moderation states.
I check for the previous and current state to eliminate messages being sent if content is able to skip steps or if I make a change and re-save it in the Needs Review state.