9
edits
m (Corrected typo, added a space) |
m (A few minor grammatical changes) |
||
| Line 10: | Line 10: | ||
=Execute your own code on a Dolibarr business event= | =Execute your own code on a Dolibarr business event= | ||
To execute personalized code after a Dolibarr event (create/modify/remove a third party/invoice/product or other), Dolibarr offers a mechanism of business triggers. This mechanism allows you to personalize a work-flow to have Dolibarr business events being synchronized into another application for example. | To execute personalized code after a Dolibarr event (create/modify/remove a third party/invoice/product or other), Dolibarr offers a mechanism of business triggers. This mechanism allows you to personalize a work-flow to have Dolibarr business events being synchronized into another application for example. | ||
You can also use triggers to modify the behavior of Dolibarr itself: for example, to create | You can also use triggers to modify the behavior of Dolibarr itself: for example, to create a contract automatically when an invoice is validated. | ||
Note that triggers is a feature for developers that is limited to business CRUD events (Create | Read | Update | Delete). There is another | Note that triggers is a feature for developers that is limited to business CRUD events (Create | Read | Update | Delete). There is another feature for developers to inject custom code in the application called the [[Hooks system]]. | ||
So, to add your own code that will be triggered by a Dolibarr trigger, this is the | So, to add your own code that will be triggered by a Dolibarr trigger, this is the process: | ||
1) Copy the trigger file '''htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN''' under the new name: | 1) Copy the trigger file '''htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN''' under the new name: <!-- Is this still accurate? --> | ||
*'''interface_99_all_''Xxx''.class.php''' | *'''interface_99_all_''Xxx''.class.php''' | ||
| Line 35: | Line 35: | ||
''htdocs/includes/triggers/interface_99_modFacture_Myworkflow.class.php'' | ''htdocs/includes/triggers/interface_99_modFacture_Myworkflow.class.php'' | ||
By creating such a file with name | By creating such a file with a name like the example, your new trigger file will be executed each time a Dolibarr business event occurs but only if the module Facture is enabled. | ||
'''Note''': With Dolibarr 3.2+, you can also place the triggers in your own module's subdirectly. Eg: if your module resides in htdocs/mymodule/, then you can place your triggers inside htdocs/mymodule/core/triggers/. But for this, you must declare the trigger into your module descriptor file (eg: '''/mymodule/core/modules/modMyModule.class.php'''). For this, add into this file triggers->1 into module_parts array: | '''Note''': With Dolibarr 3.2+, you can also place the triggers in your own module's subdirectly. Eg: if your module resides in htdocs/mymodule/, then you can place your triggers inside htdocs/mymodule/core/triggers/. But for this, you must declare the trigger into your module descriptor file (eg: '''/mymodule/core/modules/modMyModule.class.php'''). For this, add into this file triggers->1 into module_parts array: | ||
edits