Home     |     MS SQL Server    |     MS SharePoint    |     MS Visual Studio    |     MS Certifications    |     MS CRM     |     MS Office    |     MSF


Cervo Technologies
The Right Source to Outsource

microsoft.public.crm

set state of an opportunity


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:

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc