Skip to content

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! ๐Ÿ’ฌ