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, 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.
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 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
{
// Import newly generated Web service proxy.
using WebService;
class Program
{
static void Main(string[] args)
{
// Create instance of service and set 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);
}
}
}
|
See Also