Share via


Delete_<part> Operation

Deletes records on a subpage of the current page.

This operation is exposed only by pages that have subpages, which are pages that have parts of type Page. For example, the Sales Order page has a part with the name SalesLines, which has PartType equal to Page and PagePartID equal to “Sales Order Subform.” The name of the operation that is exposed by the Sales Order page is Delete_SalesLines.

When you call this operation, you delete a record of the subpage. When you call Read on a page that has a subpage, you get the records of the top-level page and the corresponding records of the subpage. To modify them or add to them, you must modify the whole top-level record.

Executing the Delete_<part> operation in a web service first executes the OnDeleteRecord Trigger on the designated record of the subpage. If application code in the OnDeleteRecord trigger for the record of the subpage returns true, then the OnDelete Trigger for the corresponding table is executed. If no fault occurs, then the record of the subpage 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 of the subpage 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_<part> operation is the return value from the page's OnDeleteRecord trigger.

If Delete returns true, then the record of the subpage has been deleted. If Delete has thrown a fault, then the record of the subpage has not been deleted. When Delete returns false, there was application logic involved, and the record of the subpage may or may not have been deleted.

Method Signature

bool Delete_<part>(string key)

Parameters

Parameter Description

key

Type: String

The bookmark of the record of the subpage, 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 of the subpage after it has been retrieved for this delete operation.

[record name] [field] [value] does not exist.

Indicates that the record of the subpage 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

This example presents a console application that is created in Visual Studio after registering and publishing the Sales Order page. For details on how to register and publish a page, see Walkthrough: Registering and Using a Page Web Service (SOAP). After you publish the page as a web service, you must also add a web reference to it. This task is also described in the walkthrough.

using Delete_SalesLinesSample.DynamicsNAVService;
namespace Delete_SalesLinesSample
{
    class Program
    {
        static void Main(string[] args)
        {
            DynamicsNAVService.SalesOrder_Binding so = new SalesOrder_Binding();
            so.UseDefaultCredentials = true;
            SalesOrder salesOrder = so.Read("2001");
            Sales_Order_Line[] salesLines = salesOrder.SalesLines;
            if (salesLines.Length > 0)
            {
                string key = salesLines[0].Key;
                so.Delete_SalesLines(key);
            }
        }
    }
}

See Also

Concepts

Basic Page Operations