I'm trying to set the state of an opportunity with just a few lines of code:
CrmService crmservice = new CrmService();
SetStateOpportunityRequest ss = new SetStateOpportunityRequest();
ss.EntityId = entityContext.InstanceId;
ss.OpportunityState = OpportunityState.Lost;
ss.OpportunityStatus = -1;
SetStateOpportunityResponse stateSet =
(SetStateOpportunityResponse)crmservice.Execute(ss);
But I get the error:
opportunity, event: postupdate, exception:
System.Web.Services.Protocols.SoapException: Server was unable to process
request.
I would really appreciate some help!
Thanks/Carina
You probably have to set the specific OpportunityStatus value, because there
is more than one possible status for a lost opportunity. Try either:
ss.OpportunityStatus = 4; // Cancelled
ss.OpportunityStatus = 5; // Out sold
David Jennaway - Microsoft Dynamics CRM MVP
Web: http://www.excitation.co.uk
"Lookup between custom attributes" wrote:
> I'm trying to set the state of an opportunity with just a few lines of code:
> CrmService crmservice = new CrmService();
> SetStateOpportunityRequest ss = new SetStateOpportunityRequest();
> ss.EntityId = entityContext.InstanceId;
> ss.OpportunityState = OpportunityState.Lost;
> ss.OpportunityStatus = -1;
> SetStateOpportunityResponse stateSet =
> (SetStateOpportunityResponse)crmservice.Execute(ss);
> But I get the error:
> opportunity, event: postupdate, exception:
> System.Web.Services.Protocols.SoapException: Server was unable to process
> request.
> I would really appreciate some help!
> Thanks/Carina