Stopping onRecordInsert() Event of a DBI file

Hi, I have a question regarding onRecordInsert() function of DBI files in Events tab.

How could I stop the saving event from occurring through this function? I remember stopping it by throwing an exception but is this the recommended way to stop it? Will it take a lot of memory at runtime?

Erik,

If you create a global method for the event (use 'create global mothod from the method selector) you get a template method.
The description gives you the info.

Rob

/**
 * Record pre-insert trigger.
 * Validate the record to be inserted.
 * When false is returned the record will not be inserted in the database.
 * When an exception is thrown the record will also not be inserted in the database but it will be added to databaseManager.getFailedRecords(),
 * the thrown exception can be retrieved via record.exception.getValue().
 *
 * @param {JSRecord} record record that will be inserted
 *
 * @returns {Boolean}
 *
 * @properties={typeid:24,uuid:"DDBFCFF3-64FC-4188-87B4-395146306FBC"}
 */
function onRecordInsert(record) {
	// TODO Auto-generated method stub
	// throw exception to pass info to handler, will be returned in record.exception.getValue() when record.exception is a DataException
	if (not_valid) throw 'cannot insert'

			// return boolean to indicate success
	return true
}

This is perfect! Thanks!