Export (0) Print
Expand All
Expand Minimize

ConvertSalesOrderToInvoice Message (CrmService)

banner art

[Applies to: Microsoft Dynamics CRM 4.0]

Works for all deployment typesWorks online only

Converts a sales order to an invoice.

The relevant classes are specified in the following table.

TypeClass
RequestConvertSalesOrderToInvoiceRequest
ResponseConvertSalesOrderToInvoiceResponse
Entitysalesorder

Remarks

To use this message, pass an instance of the ConvertSalesOrderToInvoiceRequest 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 ConvertSalesOrderToInvoice Privileges.

Example

The following code example demonstrates how to convert a sales order to an invoice.

[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 Column Set
// This Column Set holds the set of the attributes to be converted to the invoice
ColumnSet cols = new ColumnSet();
cols.Attributes = new string [] {"name", "accountid", "salesorderid", "invoiceid"};

// Create the Request
ConvertSalesOrderToInvoiceRequest convert = new ConvertSalesOrderToInvoiceRequest();
convert.ColumnSet = cols;
// SalesOrderId is the Guid of the Sales order to be converted
convert.SalesOrderId = new Guid("DD58E205-52EB-4C61-9271-8242D75859E3");

// Execute the Request
ConvertSalesOrderToInvoiceResponse converted = (ConvertSalesOrderToInvoiceResponse)service.Execute(convert);
[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 Column Set
' This Column Set holds the set of the attributes to be converted to the invoice
Dim cols As New ColumnSet()
cols.Attributes = New String() {"name", "accountid", "salesorderid", "invoiceid"}

' Create the Request
Dim convert As New ConvertSalesOrderToInvoiceRequest()
convert.ColumnSet = cols
' SalesOrderId is the Guid of the Sales order to be converted
' convert.SalesOrderId = new Guid("DD58E205-52EB-4C61-9271-8242D75859E3");
convert.SalesOrderId = orderId

' Execute the Request
Dim converted As ConvertSalesOrderToInvoiceResponse = CType( _
            service.Execute(convert), ConvertSalesOrderToInvoiceResponse)

See Also

Concepts

Reference


© 2010 Microsoft Corporation. All rights reserved.


Show:
© 2014 Microsoft