Deletes a single record.
Executing the Delete operation in a web service first executes the OnDeleteRecord Trigger on the designated page. If application code in the OnDeleteRecord trigger for the page returns true, then the OnDelete Trigger for the corresponding table is executed. If no fault occurs, then the record is deleted from the database.
If the application code in the trigger returns false, then the OnDelete trigger is not executed. This does not necessarily mean that the record has not been deleted because it may have been deleted explicitly by the application code for the page's OnDeleteRecord trigger.
The return value from the Delete operation is the return value from the page's OnDeleteRecord trigger.
If Delete returns true, then the record has been deleted. If Delete has thrown a fault, then the record has not been deleted. But when Delete returns false, then this indicates that there was application logic involved, and the record may or may not have been deleted.
Method Signature
bool Delete(string key)
Parameters
Parameter | Description |
---|---|
key | Type: String The bookmark of the record, including both primary key and concurrency information. |
Results
Result name | Description |
---|---|
Delete_Result | Type: Boolean The value that is returned by the OnDeleteRecord page trigger. |
Faults
SOAP fault message | Description |
---|---|
Other user has modified [record name]. | Indicates that another user or process has modified the record after it has been retrieved for this delete operation. |
[record name] [field] [value] does not exist. | Indicates that the record has been deleted by another user or process after it has been retrieved for this delete operation. |
Other faults are possible if they are generated by the C/AL code.
Usage Example
C# | Copy Code |
---|---|
using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication { // Imports newly generated web service proxy. using WebService; class Program { static void Main(string[] args) { // Creates instance of service and sets credentials. Customer_Service service = new Customer_Service(); service.UseDefaultCredentials = true; Customer cust = new Customer(); cust.Name = "Customer Name"; service.Create(ref cust); cust = service.Read(cust.No); service.Delete(cust.Key); } } } |