Compartilhar via


CancelSalesOrderRequest Class

Definition

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

public ref class CancelSalesOrderRequest sealed : Microsoft::Xrm::Sdk::OrganizationRequest
[System.Runtime.Serialization.DataContract(Namespace="http://schemas.microsoft.com/crm/2011/Contracts")]
public sealed class CancelSalesOrderRequest : Microsoft.Xrm.Sdk.OrganizationRequest
[<System.Runtime.Serialization.DataContract(Namespace="http://schemas.microsoft.com/crm/2011/Contracts")>]
type CancelSalesOrderRequest = class
    inherit OrganizationRequest
Public NotInheritable Class CancelSalesOrderRequest
Inherits OrganizationRequest
Inheritance
CancelSalesOrderRequest
Attributes

Examples

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 instance.

/// <summary>
/// Demonstrates the CancelSalesOrder message
/// </summary>
/// <param name="service">The authenticated IOrganizationService instance</param>
/// <param name="quoteId">The ID of a quote to convert to a sales order</param>
static void CancelSalesOrderExample(IOrganizationService service, Guid quoteId)
{
      // Define columns to be retrieved after creating the order
      var salesOrderColumns = new ColumnSet("salesorderid", "totalamount");

      // Convert the quote to a sales order
      ConvertQuoteToSalesOrderRequest convertQuoteRequest = new()
      {
         QuoteId = quoteId,
         ColumnSet = salesOrderColumns
      };

      var convertQuoteResponse =
         (ConvertQuoteToSalesOrderResponse)service.Execute(convertQuoteRequest);

      Entity closeSalesOrder = convertQuoteResponse.Entity;

      CancelSalesOrderRequest request = new()
      {
         OrderClose = new Entity("orderclose")
         {
            Attributes =
            {
                  {"salesorderid",closeSalesOrder.ToEntityReference() },
                  {"subject","Close Sales Order " + DateTime.Now }
            }
         },
         Status = new OptionSetValue(-1)
      };
      service.Execute(request);
}

Remarks

This message requires Dynamics 365 Sales.

For the Web API use the CancelSalesOrder action.

Usage

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 table. The privileges required are prvCreateActivity,prvAppendToOrder,prvAppendActivity,and prvWriteOrder.

Constructors

CancelSalesOrderRequest()

Initializes a new instance of the CancelSalesOrderRequest class.

Properties

ExtensionData

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

(Inherited from OrganizationRequest)
Item[String]

Gets or sets the indexer for the Parameters collection.

(Inherited from OrganizationRequest)
OrderClose

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

Parameters

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

(Inherited from OrganizationRequest)
RequestId

Gets or sets the ID of the request. Optional.

(Inherited from OrganizationRequest)
RequestName

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

(Inherited from OrganizationRequest)
Status

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

Applies to

See also