There's currently no way to set $node->workflow_comment without in-line php in a rule action. This patch adds workflow_comment as an optional parameter to the action. It has no validation, and I'm not sure what to do about that -- I don't see any validation of the workflow comment EVER happening, so I'm not sure what code I should invoke or duplicate.

It benefits/suffers from the use of global user in the underlying workflow state transfer to assign uid to the db record of the workflow comment. In other words, if you expose the action via a rules action and expose that component to the user with VBO (my exact use case) then the user who uses the VBO will have their comment properly attributed to them.

It works for me.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

antojose’s picture

Thanks for the above patch! Just what I was looking for.

I am working with the latest dev version: "7.x-1.0+20-dev".

Adding the code mentioned in the above patch (and flushing site cache),
on the rule's Edit Action page, we see a new text area asking for the Workflow comment to be used while changing the state.
And the comment was getting applied during the state change.

But there was one issue:
There will be two updates in the Workflow History for each Rule triggered workflow reaction -
One showing the change of state from old state X to new state Y, with the specified comment,
followed by another showing both the Old and New states as Y, and having the specified comment.

See the following image for an example:
Duplicate Workflow State Change
The later one (the crossed row in the above image) is unwanted. It is an unwanted duplicate of the row beneath it.

We have to unset $node->workflow_comment after use, to fix this.

antojose’s picture

Issue tags: +comment, +workflow, +rules, +change workflow state, ++patch
FileSize
1011 bytes

Attaching the updated patch for the latest dev version (7.x-1.0+20-dev) of the module, with the fix for the issue mentioned in the previous comment.

NancyDru’s picture

Status: Needs review » Fixed

Committed, attributed to antojose.

antojose’s picture

Thank You!

NancyDru’s picture

Status: Fixed » Closed (fixed)