I've created a patch that allows the workflow_select_given_state action to schedule states transitions at a given time after the activation of the trigger (e.g. +1day, +2months). I use it for creating a publishing workflow, where documents are automatically scheduled for review 1 year after their creation, to ensure they are still current.
The only major change to the module is that the workflow_scheduled_transition table needs to be cleaned before the actions are triggered, otherwise the cleaning process will erase the scheduled transition. If anyone knows of a good reason why the cleanup must occur before the trigger, then I'll need to rethink how this could work.
Comment | File | Size | Author |
---|---|---|---|
#4 | workflow.module.patch | 6.46 KB | adaven |
#1 | workflow.module.patch | 6.85 KB | adaven |
workflow.module.patch | 6.23 KB | adaven | |
Comments
Comment #1
adaven CreditAttribution: adaven commentedupdate: some tidying up and an addition form validation check to make sure transition time occurs in the future.
Comment #2
japanitrat CreditAttribution: japanitrat commentedThere is definitely something wrong with the timezone handling, either in workflow_schedule_transition, workflow_transition, or your action modification.
Comment #3
japanitrat CreditAttribution: japanitrat commentedworkflow_schedule_transition likes to have the scheduled date with user/site timezone already applied (which is then eliminated there), but the action is giving the raw scheduled time.
Comment #4
adaven CreditAttribution: adaven commentedGood spot japanitrat. This patch should honour the user timezone properly.
Comment #5
Anonymous (not verified) CreditAttribution: Anonymous commentedI want to resurrect this patch and inquire about the possibility of modifying this patch, if you could, to accomodate the scheduling of the email actions as well, the tokenized one more importantly, for me... but I would image it would be roughly the same for both.
Is this something that could be done? I'm not that good at editing php and whatnot that looks this intricate.
Would be an awesome addition to the capabilities of workflow.
Infact, all actions should have a "schedule execution" field that is automated and defined via the action configuration itself, and now by the administrator/user having to trigger the move to another workflow... this makes things more automated, it seems.
Raff
Comment #6
sethcohn CreditAttribution: sethcohn commentedBump. Need this sort of functionality.
I was going to reinvent the wheel when I came across this. If it's not destined to be rolled into workflow,
can we (ok, if nobody else pipes up, I) make it a new contrib module adding an 'improved' version of workflow_select_given_state_action maybe called workflow_select_given_state_scheduled_action, (and perhaps an equiv for workflow_select_next_state_scheduled_action)?
Functionally, nothing else does this, and it's such a nifty idea.
Usage case: Add this action to trigger when a node is set to workflowstate1, to schedule after +X time, to transition to workflowstate2. Potentially, that might trigger a new action to schedule moving after +Y time to workflowstate3, etc.
This would allow automatic progression thru a workflow, so for example, write a draft, publish it (workflow1), and after 2 weeks, it'll change to 'older' (workflow2) (and maybe also turn off comments, for example, which is a trivial action to write as well), then after 1 month more, change to 'archive' (workflow3) and add a "behind pay wall" permission/access flag (for example)
Essentially automated, based purely on time after putting it into workflow1.
Comment #7
sethcohn CreditAttribution: sethcohn commentedOk, I've turned the core idea here into a small contrib module, which I'd be glad to share... BUT....
One patch to workflow.module is needed, I believe, because of the ordering of events...
and it's in the above patch which never made it in (and is now pretty obsolete codewise)
Does anyone object to the above change??? (Moving the schedule clearing to BEFORE the "transition post" invocation?) There should be no difference between rules and actions, but here there is... and it's a showstopper for having any scheduling actions for workflow.
Comment #8
sethcohn CreditAttribution: sethcohn commentedretitle for clarity, and hopefully fresh eyeballs on proposed minor change to order of calls in main module.
Comment #9
MilanT CreditAttribution: MilanT commentedHello Seth,
The idea you have above is exactly what I am in dire need of. I am using my workflow to go through states and using these state changes to send out emails as notifications(using triggered rules). My workflow consists of states: pending, approved, 2 months till expiration, 1 month till expiration, 10 days till expiration, and expired.
I was curious if the code above is available somewhere for download, or am I to simply paste it into existing workflow module code. I am only a couple of months into using Drupal, so please excuse my ignorance.
Thanks in advance, and great job with this useful addition!!!
Regards,
Milan
Comment #10
q0rban CreditAttribution: q0rban commentedSeems like something like this could already be accomplished with Rules?
Comment #11
sethcohn CreditAttribution: sethcohn commentedq0rban: yes, if you use Rules... but the point here is to fix workflow, not requiring replacing it with the rules module
Comment #12
Bastlynn CreditAttribution: Bastlynn commentedRules can do this pretty handily.
Since this request is over a year old, I'm going to assume a solution was found or you've moved on. If not, please get updated to the latest versions of all modules and make a request for it against Drupal 7 and I'll be glad to take a look at it.
Comment #13
johnvJust to be sure, adding this to the meta issue, as an example.
Comment #14
johnv