Monday, 11 March 2013

Mscrm 2011 C# code to close the opportunity as Lost :

 public void CloseOpportunitiesAsLost(IOrganizationService service, Guid opportunityId)
        {

            Entity entity = new Entity("opportunityclose");
            entity["opportunityid"] = new EntityReference("opportunity", opportunityId);
            entity["actualend"] = DateTime.Now;
            LoseOpportunityRequest woReq = new LoseOpportunityRequest();            
            woReq.OpportunityClose = entity;
            woReq.Status = new OptionSetValue(-1);
            service.Execute(woReq);

        }

No comments:

Post a Comment