Sample code to override the handlerAfterInsertRow method

public void handleAfterInsertRow(Connection con, HandlerContext context, BaseModel row) throws Exception {

    //cast it to RPCModelData - using this you can access to the data thats been inserted
     RPCModelData data = (RPCModelData) row;

   //use the HandlerContext object to get access to ScriptUtil
    ScriptUtil db = context.getScriptUtil();

    //Its a custom method that creates a XML file
    InputStream xmlStream = writeXMLFile(data);

    //generate a sequence id using the ScriptUtil utility methods
     double xmlId = db.getNextVal("T_APP_NOTE_XML_S");

    //Use the connection object to write data into a table
     insertXML(con, context, data, xmlStream, xmlId);

    //use the sendEmail method to sent an email
     String noteTitle = row.get("title");
     String subject = "New Note Created - " + noteTitle;
     db.sendEmail("[email protected]", null, subject, "Email content", "N");
 }

Once you have the java class compiled and ready, enter the fully qualified class name in the "Object Handler Class" field on the data source header.

Last updated

Was this helpful?