Posted by capcase on February 9, 2009 at 7:52pm
i have a workflow associated with a particular node. how could I programmatically change
the node state from X to Y. because my node is also programmatically created via drupal_execute(...)
thanks!
Comments
actions_do() maybe
I am trying to do the same thing, as I want the state to always go from draft -> review when edited by the author of the node, so that the author and the reviewer can toss the node back and forth.
Currently I have created a custom action that will place the node in 'review' state and force it, however I am having a hard time figuring out the syntax for activating this via actions_do() in my form submit.
Any help on this? My code is like this currently (though bound to change in about 30 seconds :) ):
<?phpfunction library_node_form_submit($form, &$form_state) {
if ($user->uid == $node->uid) {
$context['target_sid'] = 3;
actions_do(10, $node, $context);
}
}
?>
workflow_execute_transition($
workflow_execute_transition($node, $sid, $comment = NULL, $force = FALSE) may help you.
creating a new node with an initial state
i would have thought this would work by simply setting something in the $node object prior to drupal_execute - but haven't stumbled upon the trick yet.
your method does work though
drupal_execute('registration_node_form', $form_state, (object)$node);
// now lets get our new node and set the state - since can't figure out how to do this any other way
$node = node_load($form_state['nid']);
workflow_execute_transition($node, $sid, NULL, true);
Peter Lindstrom
LiquidCMS - Content Solution Experts
Works no more
Both the functions doesn't work anymore...
$node= node_load(nid);
workflow_transition($node, $sid);
$node= node_load(nid);
workflow_execute_transition($node, $sid, NULL, true);