Wednesday, May 2, 2012

Close an Opportunity Record as Won In Microsoft Dynamics CRM 2011 Using VB.NET

This illustration shows how to close an opportunity record as won in Microsoft Dynamics CRM 2011 in code in VB.NET  using WinOpportunityRequest.

Ok, here is what the code look like!

Dim req As New WinOpportunityRequest()
Dim opClose As New OpportunityClose()
opClose.OpportunityId = New EntityReference(Opportunity.EntityLogicalName, New Guid("f66a58b1-6847-e111-8d3c-1cc1def1353b"))
Dim osvStatus = New OptionSetValue(3)
req.Status = osvStatus
req.OpportunityClose = opClose
Dim resp As WinOpportunityResponse = DirectCast(service.Execute(req), WinOpportunityResponse)

Thats all there is to it!

I hope this helps!

No comments:

Post a Comment