Monday, December 8, 2014

Stop deletion of record from a table

Recently came across an issue where records from customized tables were being deleted occasionally. Following wat did a quick fix for me to stop further records delete from table. 

Overwrite delete method on table and comment super(). This also stops deletion from code, e.g. if we write query delete_from table this commented super will prevent user to delete record from table.

public void delete()
{
    //super();
}

This will also stop deletion from code too. e.g.

It worked fine but records can also be deleted by pressing Ctrl+F9 on table browser. To handle this situation I overwrite validateDelete method on table and returned False from there.

public boolean validateDelete()
{
    boolean ret;

    ret = super();

    return false;

}