vtiger510:Workflow

From http://wiki.vtiger.com/archives

Faq | Howto

About

Work flow module provides a simple interface to add actions upon save of an entity. These actions will be triggered when the given conditions are met. There are three predefined Tasks currently available

  • Email Task - setup a workflow to send a new Email when the condition is matched..
  • Event Task - setup a workflow to create a new calendar Event when the condition is matched.
  • To Do Task - setup a workflow to create a new calendar todo when the condition is matched.

To know more about these Tasks click here .

Also we have Custom Task function of entity method tasks which will call certain specific methods on the Vtiger entity objects. Custom Tasks provides a way for developers to add custom actions to workflows. Let us walk through creating a Custom Task. 

NOTE:

Please be careful while making any changes, it would be good you take backup of your database first


Example

For example let us create a Work flow for Invoice module which will update the Product's stock quantity when an invoice is created.

First we need to register method that will be performing the above operation, 

Let the method be defined in the file called include/InventoryHandler.php ,then we have to register this method with our Event Manager as shown below


require_once 'include/utils/utils.php';
require 'modules/com_vtiger_workflow/VTEntityMethodManager.inc';
$emm = new VTEntityMethodManager($adb);

//$emm->addEntityMethod("Module Name","Label", "Path to file" , "Method Name" );
$emm->addEntityMethod("Invoice", "Update Inventory", "include/InventoryHandler.php", "handleInventoryProductRel");


Once this is done the name of the method will appear in the invoice module Work flow as shown below

vtiger510-workflow-UpdateInventorymethod.PNG


In InventoryHandler.php file we will get all the product for the newly created Invoices and update their quantity currently in stock. The follwing code snippet in InventoryHandler.php demonstrate's

function handleInventoryProductRel($entity){

     require_once("include/utils/InventoryUtils.php");

     updateInventoryProductRel($entity);

}



Personal tools