Deletes a record in a C/SIDE table.
|
[Ok :=] Record.DELETE([RunTrigger])
|
Parameters
- Record
-
Type: Record
The record to be deleted. The record itself does not change.
- RunTrigger
-
Type: Boolean
This optional parameter specifies whether to run the C/AL code
in the OnDelete
Trigger.
If this parameter is true, then the code in the OnDelete
trigger will be executed. If this parameter is false
(default), then the code in the OnDelete trigger will not be
executed.
The default value is false.
Property Value/Return Value
Type: Boolean
true if the record was deleted. false if the
record was not deleted because it could not be found in the table
or if the user did not have the correct permissions. If the C/AL
code terminates, false is returned.
If the record does not exist and you do not include a return
value, the function will terminate with a run-time error.
Remarks
Example
These examples show how to use the DELETE function. The
first example does not use the return value from the DELETE
function. This means that a run-time error occurs if the record to
be deleted cannot be found.
The second example shows how you can handle errors
using the return value.
These examples require that you create the following
variables and text constants in the C/AL Globals window.
Variable name |
DataType |
Subtype |
CustomerRec
|
Record
|
Customer
|
Text constant name |
ENU Value |
Text000
|
The customer has been deleted.
|
Text001
|
The customer could not be found.
|
|
Copy Code |
// Without using the return value:
CustomerRec."No." := '100';
CustomerRec.DELETE;
// Using the return value:
CustomerRec."No." := '100';
IF CustomerRec.DELETE THEN
MESSAGE(Text000)
ELSE
ERROR(Text001);
|
See Also