CancelSalesOrderRequest CancelSalesOrderRequest CancelSalesOrderRequest CancelSalesOrderRequest Class


Contains the data that is needed to cancel a sales order (order).

For the Web API use the CancelSalesOrder Action.

public ref class CancelSalesOrderRequest sealed : Microsoft::Xrm::Sdk::OrganizationRequest
public sealed class CancelSalesOrderRequest : Microsoft.Xrm.Sdk.OrganizationRequest
type CancelSalesOrderRequest = class
    inherit OrganizationRequest
Public NotInheritable Class CancelSalesOrderRequest
Inherits OrganizationRequest


// Define columns to be retrieved after creating the order
salesOrderColumns = new ColumnSet("salesorderid", "totalamount");

// Convert the quote to a sales order
var =
    new ConvertQuoteToSalesOrderRequest()
        QuoteId = _quoteId,
        ColumnSet = salesOrderColumns

convertQuoteResponse = (ConvertQuoteToSalesOrderResponse)svc.Execute(convertQuoteRequest);
SalesOrder closeSalesOrder = (SalesOrder)convertQuoteResponse.Entity;
_closeSalesOrderId = closeSalesOrder.Id;

var cancelRequest = new CancelSalesOrderRequest()
    OrderClose = new OrderClose()
        SalesOrderId = closeSalesOrder.ToEntityReference(),
        Subject = "Close Sales Order " + DateTime.Now
    Status = new OptionSetValue(-1)
Console.WriteLine("Canceled sales order");

The following example shows how to use this message. For this sample to work correctly, you must be connected to the server to get an IOrganizationService interface. For the complete sample, see the link later in this topic.



Message Availability

This message works regardless whether the caller is connected to the server or offline.


Pass an instance of this class to the Execute(OrganizationRequest) method, which returns an instance of the CancelSalesOrderResponse class.

Privileges and Access Rights

To perform this action, the caller must have privileges on the SalesOrder entity. For a complete list of the required privileges, see CancelSalesOrder message privileges.


CancelSalesOrderRequest() CancelSalesOrderRequest() CancelSalesOrderRequest() CancelSalesOrderRequest()

Initializes a new instance of the CancelSalesOrderRequest class.


ExtensionData ExtensionData ExtensionData ExtensionData

Gets or sets the structure that contains extra data. Optional.

(Inherited from OrganizationRequest)
Item[String] Item[String] Item[String] Item[String]

Gets or sets the indexer for the Parameters collection.

(Inherited from OrganizationRequest)
OrderClose OrderClose OrderClose OrderClose

Gets or sets the close activity that is associated with the sales order (order) that you want to cancel. Required.

Parameters Parameters Parameters Parameters

Gets or sets the collection of parameters for the request. Required, but is supplied by derived classes.

(Inherited from OrganizationRequest)
RequestId RequestId RequestId RequestId

Gets or sets the ID of an asynchronous operation (system job). Optional.

(Inherited from OrganizationRequest)
RequestName RequestName RequestName RequestName

Gets or sets the name of the request. Required, but is supplied by derived classes.

(Inherited from OrganizationRequest)
Status Status Status Status

Gets or sets the status of the sales order (order). Required.

Applies to

See also