Search code examples
dynamics-crm-2016

Dynamics Crm online 2016 set opportunity statecode


I am looking for the C# (console application) syntax required to set the statecode of an opportunity to "not active" or "closed". In fact I would also like to know where I can find the available values for statecode, since in the field properties I see that the datatype is "Status", but I don't see the available values.

Thank you in advance


Solution

  • Valid state codes for Opportunity:

    statecode        -   statuscode 
    0 (Open)         -   1 (In Progress), 2 (On Hold)
    1 (Won)          -   3 (Won)
    2 (Lost)         -   4 (Cancelled), 5 (Out-Sold)
    

    Because you want to "Close" the opportunity, use LoseOpportunityRequest SDK message to "Cancel" the opportunity.