This is an old revision of the document!


Execution via PHP

You could execute a workflow manually in your own vtigerCRM extension or PHP file.
You only need the following PHP Code:

   $current_user = new Users();
   $current_user->id = <executingUserID>;
   $current_user = $current_user->retrieve_entity_info(<executingUserID>, "Users");
 
   $objWorkflow = new WfMain(<workflowID>, false, $current_user);
 
   $newObj = Workflow_VTEntity::getById("<recordID>");
   $newObj->loadEnvironment(array("asd" => "asd"));        // Variables, which will be available inside the Workflow in $env
 
   $objWorkflow->setContext($newObj);
   $objWorkflow->start();