Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 79901

Closing Won Opportunity as Lost

$
0
0

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


Viewing all articles
Browse latest Browse all 79901

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>