Deleting Records in List Blocks

Records can be deleted from blocks containing multiple rows, either from a child block or on a screen in list mode.  

The code for this is simply:

DeleteThisRow();

The code will create a delete statement against the table assigned to the block with a where clause including the key fields and values for the block.  For example, if deleting an item number from table item_master_uvw in an Oracle datasource, where the primary key marked for the block is the item_no field and the item number being deleted is ITEM0001, the delete statement would be generated as:

DELETE FROM ITEM_MASTER_UVW WHERE ITEM_NO = 'ITEM0001'

Creating Delete Links

  1. To create a Delete link, if rows can be deleted, add a field to the block that is a non-database field.  

  2. Set up the field as a Hyperlink field.  Set the Hyperlink Scripted flag to true.

  3. In the Hyperlink property for the new field, enter DeleteThisRow();

  4. Press the Save button.

Possible Modifications to the Delete Link

The Delete link can contain additional checks, such as verifying that the user wants to delete the record, or if you have new rows, checking to make sure the row exists before deleting the row.  In addition, for new rows, there is different code to clear the record because the row doesn't yet exist in the database.

var agree=confirm('Do you wish to delete this record?');

if (agree)

   {DeleteThisRow();}

if(RowExists())

  {DeleteThisRow();}

ResetRow();

You can combine all of the code above as follows:

var agree = confirm('Delete this Record?');

if (agree)

   {

     if(RowExists())

         { DeleteThisRow(); }

     else

         { ResetRow(); }

   }