How do you re-open a closed Opportunity with the SDK?

How do you re-open a closed Opportunity with the SDK?

Post by QmlsbCBBbH » Wed, 22 Apr 2009 12:08:12


This
if (opp.statecodename == "Lost"){
SetStateOpportunityRequest openRequest = new
SetStateOpportunityRequest( );
openRequest.EntityId = opp.opportunityid;
openRequest.OpportunityState = OpportunityState.Open;
openRequest.OpportunityStatus = -1;
SetStateOpportunityResponse openResponse =
(SetStateOpportunityResponse)service.Execute( openRequest );

throws this exception:
0x80040216
An unexpected error occurred.

}
 
 
 

How do you re-open a closed Opportunity with the SDK?

Post by UmFtYXN1Yn » Thu, 23 Apr 2009 02:05:03

Hi Bill,

Use SetStateDynamicEntity request. Following is the sample.

SetStateDynamicEntityRequest a = new SetStateDynamicEntityRequest();
a.Entity = new Moniker();
a.Entity.Id = new Guid("RecordID");
a.Entity.Name = "new_customentity";
a.State = "active"
a.Status = 1;

service.Execute(a);

Hope this helps.

Ramasubramanian

 
 
 

How do you re-open a closed Opportunity with the SDK?

Post by QmlsbCBBbH » Thu, 23 Apr 2009 09:52:03

This:
Moniker moniker = new Moniker( );
moniker.Id = opp.opportunityid;
moniker.Name = EntityName.opportunity.ToString( );

SetStateDynamicEntityRequest a = new SetStateDynamicEntityRequest();
a.Entity = moniker;
a.State = "open";
a.Status = 1; // or a.Status = -1;

produces:

ex.Detail.InnerText "\n 0x80040216\n An unexpected error occurred.\n
Platform\n"
 
 
 

How do you re-open a closed Opportunity with the SDK?

Post by QmlsbCBBbH » Thu, 23 Apr 2009 12:09:01

But it works when you put a value in at least one Opportunity money field.
In this Org the Opportunity form exposes no money fields.
When you try to Reopen the Opportunity through the form Actions
a NullReferenceException is thrown by
Microsoft.Crm.ObjectModel.DefaultCurrency.
 
 
 

How do you re-open a closed Opportunity with the SDK?

Post by rakesh aga » Thu, 23 Apr 2009 16:00:21

On Apr 22, 8:09m, Bill Altmann


Have you tried by workflow.

regards
Rakesh Agarwal
http://www.yqcomputer.com/