Hello all,

I am working on a project and i was wondering if there is a way to transition to workflow states automatically. For instance, I want to create workflow states: 1.Created 2.Idle 3.Abandoned 4.Edited 5.Published . So here is what i want the states to do:

If new content is created, it is assigned the state "created".

If the content is not edited for a particular period, say 1 week, it is automatically assigned the state "Idle"

If content is edited before the expiration of the admin selected "idle" period, then it can be moved to the state "Edited". etc.

Here is the use case:

  • Manager creates a content and assigns this node to one of the workers using the user reference cck field.
  • If worker is too lazy and didnt work on the node after 1week, then the workflow state is automatically set to "idle" and an admin pre-configured email reminder is automatically generated and sent to worker (user referenced) and a copy also sent to manager (original author).
  • After 2 weeks of inactivity, that is, the worker still did not do anything on the node, the workflow state is set automatically to "abandoned" and another admin pre-configured "disciplinary query" email is generated and sent to worker, and a copy also sent to manager for record purposes.

Comments

smartsystems160’s picture

Issue summary: View changes

Hello all

johnv’s picture

Issue summary: View changes

Moving all remaining D6 issues to D7.

johnv’s picture

Version: 6.x-1.x-dev » 7.x-2.x-dev
johnv’s picture

Title: Transition to workflow state automatically with email capability » Add ability to automatically schedule Transitions after state change.

Better title.
Sending emails after state change should be possible with or without scheduled transitions.

smartsystems160’s picture

Would be glad to see this possible. Using drupal 7 now.

johnv’s picture

Hi there, have you some workaround at the moment?
I'm not sure if this is in scope of this project.

I can see the following requirements, whch may or may not be in scope of this project, and may or may not be already achievable with another module:
- on a certain time, execute an action (= execute a state change)
- if the start/end date of a date field has passed, execute an action (= execute a state change)
- if the start/end date of a date field has passed a certain time, execute an action (= execute a state change)
- if the start/end date of a date field will expire within a certain time, execute an action (= execute a state change)
- if a state change has occurred, schedule another action to happen after a certain time.
- if a state change has occurred and the state has not changed within this time, schedule/execute another action.

Here are some options:
Rules Scheduler:
- http://codekarate.com/daily-dose-of-drupal/drupal-7-rules-scheduler-part-3 (the introtext implies that Rules Scheduler can do all of the above.)
- https://drupal.org/node/1068136
- https://drupal.org/node/1582254
- https://drupal.org/node/517674

https://drupal.org/project/scheduler (Unfortunately, this does not work on any date field - Scheduler provides her own field)
- https://drupal.org/node/2177387

https://drupal.org/project/scheduled_actions

johnv’s picture

2 new approaches have arisen:
- #2237125: Adopt tokens from workflow_extensions provides a new token [node:workflow-current-state-age-seconds]. (included in current dev-version, or 7.x-2.3)
With this , you can create a Rule. See the project page of the Workflow Extensions module for a manual.
Be aware: I'm planning on restructuring (adding) better tokens, to allow multiple workflows per node.
- #2217017: Rules action to check workflow field state and to schedule transition provides a way to schedule an action.

johnv’s picture

johnv’s picture

Version: 7.x-2.x-dev » 8.x-1.x-dev
johnv’s picture

Title: Add ability to automatically schedule Transitions after state change. » Add ability to automatically schedule Transitions after state change
Parent issue: #486592: How to schedule a following Fixed date transition » #2144747: [META] Flexible transitions
johnv’s picture

Please also see the script here: https://www.drupal.org/project/workflow_extensions, under 'Appendix: using Rules to invoke actions after a period of inactivity'

sascher’s picture

Hello

I am trying to make this happen as well by creating an ECA model that creates a Workflow Scheduled Transition entity. Is anyone else trying this approach?

I keep getting the error

TypeError: workflow_node_current_state(): Argument #1 ($entity) must be of type Drupal\Core\Entity\EntityInterface, null given, called in //modules/contrib/workflow/src/Entity/WorkflowTransition.php on line 868 in workflow_node_current_state() (line 431 of modules/contrib/workflow/workflow.module).

johnv’s picture

Which version are you using? Please use 2.0 dev version.. 1.8+dev version. This is the dev version for upcoming 2.1.0

sascher’s picture

I was using Workflow version 2.0 not 1.8, but I will definitely try the dev version of the module

sascher’s picture

I changed to the 1.8 dev version of the module and the WSOD went away but now it looks like we can not even create the workflow scheduled transition entity anymore using ECA

johnv’s picture

INdeed, I noticed. I reverted a change just now: #3529350-5: Modernize from Annotations to Attributes