Edit After Save Event in Merciglobal Cloud ERP
Overview
The Edit After Save event (_edit_aftersave
) is a customizable event hook in Merciglobal Cloud ERP. It is triggered after a new record is successfully inserted into the database. This event is particularly beneficial for executing additional operations post-record creation, such as logging, sending notifications, or initiating workflows.
โ ๏ธ Note: Events are applicable only for form tables.
Function Signature
Add the custom logic in the /libfuncs.php
file.
function _edit_aftersave($nNewMasterID = 0) {
// Your custom logic here
}
๐ Note: Replace
tablename
with the specific table you are targeting.
Parameters:
-
\$nNewMasterID (int): The unique identifier of the newly inserted record.
-
Automatically passed by the system upon record creation.
- Useful for retrieving or manipulating the data after editing and saving.
Use Cases
Here are practical applications for this event:
- ๐ Send confirmation emails after editing a record.
- ๐งพ Auto-generate reference codes or custom identifiers.
- ๐งฎ Perform backend calculations or update associated tables.
- ๐๏ธ Create audit trail logs for traceability.
- ๐ Launch background processes or automation tasks.
Example Implementation
Below is an example illustrating how to use this event to log a new record ID:
function trn_salesinvoice_edit_aftersave($nNewMasterID = 0) {
// Example: Log to a file or database
error_log("Record inserted with ID: $nNewMasterID");
}
Tips for Developers
- โ
Validate
$nNewMasterID
before using it in any database operations. - โ๏ธ Avoid heavy processing within the event functionโconsider asynchronous jobs or queues.
- ๐งฉ Modularize your code: Use service/helper classes for complex logic.
Summary Table
๐ Feature | ๐ Description |
---|---|
Event Name | _edit_aftersave |
Trigger Time | After a record is saved (inserted) |
Key Parameter | $nNewMasterID - Unique ID of the new record |
Main Use Cases | Logging, Email Alerts, Reference Generation, Integrations |
๐ Merciglobal Cloud ERP empowers your team with intelligent, event-driven extensibility. Need assistance? Contact the Merci Developer Support Team today! ๐ฌ