How run workflow from code

I have a custom workflow, how can i run one of the workflow by code.
I will create a new button for do that, a custom action or in controller.


bump :slight_smile:

can you share what you want to achieve? with an example maybe?

best regards


create a basic workflow, say it “Send email to Contact Case Closure Template”.
when a case is closed, workflow send a email with case closure template.

What i will, is create a button in detail view… who launch (run) this workflow.

in // SuiteCRM/modules/AOW_WorkFlow/AOW_WorkFlow.php
you have function run_actions(SugarBean &$bean, $in_save = false){

i will do something like this in my controller :


class CustomAccountsController extends SugarController { 

	function action_Run_Workflow() 
       run_flow();  // SuiteCRM/modules/AOW_WorkFlow/AOW_WorkFlow.php
     or this  run_actions($bean);

    $flow = new AOW_WorkFlow();
   $flow->run_actions($bean, true);