deleteRecord
This function deletes the current record or a specified record from the database. It provides options to bypass the confirmation dialog and triggers appropriate events before and after deletion.
Syntax
app.deleteRecord(options)
Parameters
Parameter | Type | Description |
---|---|---|
options | Object/Number | Either a record ID (Number) or an options object with the following properties |
options.id | Number | (Optional) The ID of the record to delete. If not provided, the current record ID (app.recordId) will be used |
options.noConfirmMessage | Boolean | (Optional) If true , the confirmation dialog will be skipped. Default is false |
Return Value
This function doesn't return a value. However, it:
- Triggers the
RecordDeleted
event if successful - Creates a new empty record if successful
- Logs the operation in the system log
Examples
Example 1: Delete the current record with confirmation dialog:
// Delete the current record with confirmation dialog
app.deleteRecord();
Example 2: Delete a specific record with confirmation dialog:
// Delete record with ID 123 with confirmation dialog
app.deleteRecord(123);
// Alternative with options object
app.deleteRecord({id: 123});
Example 3: Delete the current record without confirmation:
// Delete the current record without showing confirmation
app.deleteRecord({noConfirmMessage: true});
Example 4: Delete a specific record without confirmation:
// Delete record with ID 123 without showing confirmation
app.deleteRecord({id: 123, noConfirmMessage: true});
Events
Event | Timing | Purpose |
---|---|---|
RecordDelete | Before deletion | Allows cancellation of the delete operation |
RecordDeleted | After successful deletion | Notifies that a record was successfully deleted |
Notes
- If the
RecordDelete
event returnsfalse
, the deletion will be canceled. - After successful deletion, a new empty record will be created via
newRecord()
. - This function adds an entry to the application log with the status of the operation.