The code looks like this:
Code: Select all
addIntranetLog("johndoe","John Doe","Access was denied to the application MyApp","Access Denied","192.168.1.123");
form.abort("Access Denied").
If I comment out form.abort the row is correctly inserted into the database.
How can I prevent this behavior or rolling back the last transaction ?
This is the shared function that inserts the log into the database:
Code: Select all
function addIntranetLog(username,realName,logMessage,logType,ipAddress) {
var sql="INSERT INTO Logs(Username,RealName,LogDate,LogMessage,LogType,IPAddress) VALUES('" + (username != null ? username : "") + "','" + system.securityManager.getCredential("REALNAME") + "',GETDATE(),'" + logMessage + "','" + logType + "','" + ipAddress + "');";
var con=system.getDatabaseConnection("MYDBCONNECTION");
var rs,stmt;
try {
stmt=con.prepareStatement(sql);
rs=stmt.execute();
} catch (e) {
// Dump the SQL for debugging purposes
print("An error occurred reading the database with the query " + sql);
print(e);
if(rs) rs.close();
if(stmt) stmt.close();
if(con) con.close();
event.stopExecution();
} finally {
if(rs) rs.close();
if(stmt) stmt.close();
if(con) con.close();
}
return;
}