Hi,
Here is the code to close an Opportunity as Lost using the MS Dynamics CRM SDK.
In this example, I am using LoseOpportunityRequest to close an Opportunity as Lost.
publicstaticvoid CloseOpportunityAsLose(IOrganizationService crmService, Guid guidOpportunityId)
{
LoseOpportunityRequest req = newLoseOpportunityRequest();
Entity opportunityClose = newEntity("opportunityclose");
opportunityClose.Attributes.Add("opportunityid", newEntityReference("opportunity", guidOpportunityId));
opportunityClose.Attributes.Add("subject", "Lost the Opportunity!");
req.OpportunityClose = opportunityClose;
OptionSetValue osvLostValue = newOptionSetValue();
osvLostValue.Value = 4;
req.Status = osvLostValue;
LoseOpportunityResponse resp = (LoseOpportunityResponse)crmService.Execute(req);
}
Hope this helps.
--
Happy CRM'ing
Here is the code to close an Opportunity as Lost using the MS Dynamics CRM SDK.
In this example, I am using LoseOpportunityRequest to close an Opportunity as Lost.
publicstaticvoid CloseOpportunityAsLose(IOrganizationService crmService, Guid guidOpportunityId)
{
LoseOpportunityRequest req = newLoseOpportunityRequest();
Entity opportunityClose = newEntity("opportunityclose");
opportunityClose.Attributes.Add("opportunityid", newEntityReference("opportunity", guidOpportunityId));
opportunityClose.Attributes.Add("subject", "Lost the Opportunity!");
req.OpportunityClose = opportunityClose;
OptionSetValue osvLostValue = newOptionSetValue();
osvLostValue.Value = 4;
req.Status = osvLostValue;
LoseOpportunityResponse resp = (LoseOpportunityResponse)crmService.Execute(req);
}
Hope this helps.
--
Happy CRM'ing
Gopinath |