Edit After Save Event in Merciglobal Cloud ERP¶
Overview¶
The Edit After Save event (<tablename>_edit_aftersave
) is a customizable event hook in Merciglobal Cloud ERP that is triggered after a new record is successfully inserted into the database.
This event is particularly useful when you want to perform additional operations after a record has been created — such as logging, sending notifications, or triggering workflows.
Attention: The events are available only for the **form tables**.
Function Signature¶
Write in /libfuncs.php
function <tablename>_edit_aftersave($nNewMasterID = 0) {
// Your custom logic here
}
Parameter:¶
- $nNewMasterID (int): The unique ID of the newly inserted record.
- This is automatically passed by the system when the record is created.
- It allows you to fetch or manipulate the data after it is being edited and saved.
Use Cases¶
Here are a few practical examples of how this event can be used:
- 🔔 Send a confirmation email to the user after editing a record.
- 🧾 Generate a reference code or custom ID based on the record ID.
- 🧮 Trigger calculations or update related tables.
- 🗃️ Log the creation into an audit trail for future traceability.
- 📊 Initiate a background job or process automation.
Example¶
Here's a simple example to log the new record ID:
function trn_salesinvoice_edit_aftersave($nNewMasterID = 0) {
// Log to file or database
}
Tips for Developers¶
- Always validate the
$nNewMasterID
before using it in queries. - Avoid long-running tasks directly inside the event — consider queuing or async operations.
- Maintain modular logic: delegate complex operations to service/helper classes.
Summary¶
🔍 Feature | 📄 Description |
---|---|
Event Name | <tablename>_edit_aftersave |
Trigger Time | After a record is saved (inserted) |
Key Parameter | $nNewMasterID - ID of the new record |
Main Use Cases | Logging, Notifications, Reference Generation, Integrations |
🚀 Merciglobal Cloud ERP continues to empower teams with smart, event-driven extensibility!
Need help implementing this? Reach out to the Merci Developer Support Team! 💬