Friday, June 30, 2006

Microsoft CRM 3.0 - Quote To Order converting. (VB.NET)

Well, this goes under the "not very obvious" category with the SDK. You
first need to "win" the Quote and to do that, you first need to setup a
"quoteclose" object that will be the activity related to the "win". Then
you can create the Order from it.

Public Function ConvertToOrder(ByVal QuoteId As String) As String
Dim WsCrm As New WsCRM30.CrmService
WsCrm.Credentials = CType(HttpContext.Current.Application("Credentials"), System.Net.ICredentials)
'***********Activate Quote
Dim SSQR As WsCRM30.SetStateQuoteRequest = New WsCRM30.SetStateQuoteRequest
SSQR.EntityId = New Guid
SSQR.EntityId = New Guid(QuoteId)
SSQR.QuoteState = WsCRM30.QuoteState.Active
SSQR.QuoteStatus = -1
Dim Resp As WsCRM30.SetStateQuoteResponse = CType(WsCrm.Execute(SSQR), WsCRM30.SetStateQuoteResponse)

' Create Quoteclose object
Dim QC As WsCRM30.quoteclose = New WsCRM30.quoteclose
QC.quoteid = New WsCRM30.Lookup
QC.quoteid.Value = New Guid(QuoteId)
QC.quoteid.type = WsCRM30.EntityName.quote.ToString()

'***********"Win" Quote
Dim WQR As WsCRM30.WinQuoteRequest = New WsCRM30.WinQuoteRequest
WQR.QuoteClose = QC
WQR.Status = -1
Dim Resp2 As WsCRM30.WinQuoteResponse = CType(WsCrm.Execute(WQR), WsCRM30.WinQuoteResponse)

Dim QToSo As WsCRM30.ConvertQuoteToSalesOrderRequest = New WsCRM30.ConvertQuoteToSalesOrderRequest
QToSo.ColumnSet = New WsCRM30.AllColumns
QToSo.QuoteId = New Guid(QuoteId)
QToSo.ReturnDynamicEntities = False

Dim RQToSo As WsCRM30.ConvertQuoteToSalesOrderResponse = New WsCRM30.ConvertQuoteToSalesOrderResponse
RQToSo = CType(WsCrm.Execute(QToSo), WsCRM30.ConvertQuoteToSalesOrderResponse)

Dim Result As String = "{" + CType(RQToSo.BusinessEntity, WsCRM30.salesorder).salesorderid.Value.ToString + "}"

Dim WSOR As WsCRM30.UnlockSalesOrderPricingRequest = New WsCRM30.UnlockSalesOrderPricingRequest
WSOR.SalesOrderId = New Guid(Result)

Dim RespSO As WsCRM30.UnlockSalesOrderPricingResponse = New WsCRM30.UnlockSalesOrderPricingResponse
RespSO = CType(WsCrm.Execute(WSOR), WsCRM30.UnlockSalesOrderPricingResponse)

Return Result

Catch SoapErr As System.Web.Services.Protocols.SoapException
Throw New Exception("Soap Error Message: " + SoapErr.Detail.InnerText)
Catch ex As Exception
Throw ex
End Try

End Function


At 10:27 AM , Anonymous Anonymous said...

Very best site

At 3:24 PM , Anonymous Anonymous said...

unbelievable! Why couldn't Microsoft share that information with us?

At 6:35 AM , Blogger Angeline said...

thank you so so so so so much. That saved me a lot of time.


Post a Comment

Subscribe to Post Comments [Atom]

Links to this post:

Create a Link

<< Home

eXTReMe Tracker