Articles in this section
Set up a Workflow Action to Invoke Custom Function
Table of Contents
Invoke Custom Function - A Workflow Action
The Workflows module provides you a simple interface to add custom actions that execute on saving an entity.
Vtiger has a Custom Task function of entity method tasks that calls certain methods on Vtiger entity objects. Custom Tasks provides a way for developers to add custom actions to workflows. Let us walk through creating a Custom Task.
For example, if you want to compute natural Math Log as a custom operation, then first we need to register a method that will perform the operation. The method needs an operation name, file path (can be anywhere, even in a custom module), and a function name.
Let’s say you have a custom module called Deals. You can register a method in the postinstall event(vtlib_handler API of Deals.php file) of the module. The event is triggered after the module is installed.
For more details on how to write a module, click here.
Setting up the workflow
Follow these steps to set up the workflow with a custom function:
Accessing the workflow page:
- Click the User Menu on the top right corner of the screen
- Click the Settings button
- Look for the Automation section
- Select Workflows
- Click the +New Workflow button
- Select Standard
Entering the basic information:
- Select the Target Module
- Enter workflow name, status, etc
Select the workflow trigger:
- Select the Workflow Trigger
Set up the workflow entry criteria:
- Click the +Add Condition button
- Enter the condition that must satisfy for the workflow to execute
Note: To learn about the basic information, trigger, and entry criteria, click here.
Set up the action:
- Click the Add Action drop-down
- Select Invoke Custom Function
- This opens a window where you must enter the Action Title
- Enter the Action Title
- Click Save to save the action
- Click Save to save the workflow
| want to update the Purchase cost of Products based on the List price given for the Product in the latest Purchase Order, do the following: |