Posted By

toLL on 07/07/12


Tagged

crm opportunity winopportunityrequest opportunityclose


Versions (?)

CRM 2011: Win Opportunity using OpportunityClose and WinOpportunityRequest


 / Published in: C#
 

How to set opportunity status to WON

  1. private void WinOpportunity(IOrganizationService organizationService, Opportunity opportunity)
  2. {
  3.  
  4. OpportunityClose oppClose = new OpportunityClose
  5. {
  6. OpportunityId = opportunity.ToEntityReference(),
  7. Subject = "Won!",
  8. ActualEnd = DateTime.Now,
  9. Description = "Won!",
  10. };
  11.  
  12. var req = new WinOpportunityRequest
  13. {
  14. OpportunityClose = oppClose,
  15. RequestName = "WinOpportunity",
  16. Status = new OptionSetValue(3)
  17. };
  18.  
  19. var response = (WinOpportunityResponse)organizationService.Execute(req);
  20.  
  21. var results = response.Results;
  22. }

Report this snippet  

You need to login to post a comment.