I'm trying to write an action which upon trigger will schedule a workflow state transition to another state at a later date. This seems to be impossible based on the event I want to respond to and how the state transition code is ordered in workflow.module.

What I want is when the node goes into my "submitted" state trigger the action to "schedule the closed state for a later date". This gets fired but the last thing that the state transition code does is clean up (delete all rows) from the {workflow_scheduled_transition} table effectively erasing my action scheduled addition.

See line 601 in // $Id: workflow.module,v 1.54.2.27 2008/04/29 16:45:05 jvandyk Exp $

Also I wanted my action only available for the "submitted" state but I could not get my action to show up in the UI unless I did 'workflow' => array('any')

ie,

      'hooks' => array(
        'workflow' => array('any'),
      ),

vs

      'hooks' => array(
        'workflow' => array('submitted'),
      ),

but I think that is a separate issue. I didn't see documentation on the workflow "hook" so maybe I used it incorrectly - maybe its hooks are defined some other way.

Here was my test code

function mymod_action_info() {
  return array(
    'mymod_schedule_closed_state_action' => array(
      'type' => 'node',
      'description' => t('Autoschedule Submission Closing for October 1, 2008'),
      'configurable' => FALSE,
      'hooks' => array(
        'workflow' => array('any'),
      ),
    ),
  );
}

function mymod_schedule_closed_state_action($node, $context) {
  // Schedule a state change to closed for October 1
  db_query("INSERT INTO {workflow_scheduled_transition} VALUES (%d, %d, %d, %d, '%s')", $node->nid, 4, 6, 1222819260, 'Submissions Auto Close');  
}

Comments

pomliane’s picture

Status: Active » Closed (won't fix)

This version of Actions is not supported anymore. The issue is closed for this reason.
Please upgrade to a supported version and feel free to reopen the issue on the new version if applicable.

This issue has been automagically closed by a script.