Expand Minimize
This topic has not yet been rated - Rate this topic

CancelSalesOrder Message (CrmService)

banner art

[Applies to: Microsoft Dynamics CRM 4.0]

Works for all deployment typesWorks online and offline

Cancels a sales order.

The relevant classes are specified in the following table.

TypeClass
RequestCancelSalesOrderRequest
ResponseCancelSalesOrderResponse
Entitysalesorder

Remarks

To use this message, pass an instance of the CancelSalesOrderRequest class as the request parameter in the Execute method.

To perform this action, the caller must have access rights on the salesorder entity instance. For a list of required privileges, see CancelSalesOrder Privileges.

Example

The following code example demonstrates how to cancel a sales order.

[C#]
// Set up the CRM Service.
CrmAuthenticationToken token = new CrmAuthenticationToken();
// You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
token.AuthenticationType = 0; 
token.OrganizationName = "AdventureWorksCycle";
 
CrmService service = new CrmService();
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Create the order close activity object.
orderclose close = new orderclose();

// Set the properties of the order close object.
close.subject = "orderclose";

// Create a Lookup for the sales order being canceled.
close.salesorderid = new Lookup();
close.salesorderid.type = EntityName.salesorder.ToString();
close.salesorderid.Value = created.id;

// Create the request object.
CancelSalesOrderRequest cancel = new CancelSalesOrderRequest();

// Set the properties of the request object.
cancel.OrderClose = close;
cancel.Status = -1;

// Execute the request.
CancelSalesOrderResponse canceled = (CancelSalesOrderResponse) service.Execute(cancel);
[Visual Basic .NET]
' Set up the CRM Service.
Dim token As New CrmAuthenticationToken()
' You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
token.AuthenticationType = 0
token.OrganizationName = "AdventureWorksCycle";
 
Dim service As New CrmService()
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials

' Create the order close activity object.
Dim close As New orderclose()

'Set the properties of the order close object.
close.subject = "orderclose"

'Create a Lookup for the sales order being canceled.
close.salesorderid = New Lookup()
close.salesorderid.type = EntityName.salesorder.ToString()
close.salesorderid.Value = created.id

' Create the request object.
Dim cancel As New CancelSalesOrderRequest()

' Set the properties of the request object.
cancel.OrderClose = close
cancel.Status = -1

' Execute the request.
Dim canceled As CancelSalesOrderResponse = CType(service.Execute(cancel), CancelSalesOrderResponse)

See Also

Concepts

Reference


© 2010 Microsoft Corporation. All rights reserved.


Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.