Hi,
As a part of a clean up we are taking out opportunities on a condition and closing them as lost, i am able to achieve the same using the code below however this code fails when the opportunity is already Won.
LoseOpportunityRequest req = new LoseOpportunityRequest();
Entity opportunityClose = new Entity("opportunityclose");
opportunityClose.Attributes.Add("opportunityid", new EntityReference("opportunity", new Guid(c)));
req.OpportunityClose = opportunityClose;
req.RequestName = "LoseOpportunity";
OptionSetValue o = new OptionSetValue();
o.Value = -1;
req.Status = o;
LoseOpportunityResponse resp = (LoseOpportunityResponse)service.Execute(req);
"c" is the GUID i pass using a "For" loop from Excel but this is the main code.
The error states that the opportunity is already closed.
Please help me in this
Thanks