blainelang
10/10/2014 - 7:00 PM

Code snippet to launch a maestro workflow

Code snippet to launch a maestro workflow




  $tracking_id = db_select('maestro_process')
    ->fields('maestro_process', array('tracking_id'))
    ->condition('id', $newprocess, '=')
    ->execute()->fetchField();

  $template_data_id = db_select('maestro_template_data')
    ->fields('maestro_template_data', array('id'))
    ->condition('task_class_name', 'MaestroTaskTypeContentType', '=')
    ->execute()->fetchField();

  db_insert('maestro_project_content')
    ->fields(array(
      'nid' => $node_wrapper->nid->value(),
      'tracking_id' => $tracking_id,
      'task_id' => 0,
      'content_type' => $node_wrapper->type->value(),
      'status'  => $status
    ))
    ->execute();

/* Code to launch a maestro workflow.
 * Pass in the template ID and security token
 * Once the workflow instance is launched, it 
 * returns the new process id
*/ 

$template = 1; // Set to the maestro template you want to launch
$sec_token = drupal_get_token('maestro_user');
$new_process_id = maestro_launch_workflow($template, $sec_token);