Available Status Codes RRS feed

  • Question

  • We have a 30 trial of Dynamics CRM 2015 online so we can test the development environment. Things are going well but we are stumped on this issue. We need to be able to retrieve a list of all the possible status codes for Leads, Opportunities, Incidents etc... using the SDK. Not only do we need each status code, we need to know for example, which of the Lead status codes represents CLOSED or CONVERTED. We are assuming these codes are configurable so we can't just assume the same codes for every instance, correct?  Can we get all the possible codes using a FetchXML query? Is this even possible? I've searched the CRM Developer forum extensively with no luck.

    Wednesday, March 25, 2015 3:21 AM


  • Hello


    Hello. The state and status codes are listed on this website: Default status and status reason values
    To get a list of all state and status codes  using the SDK, I just can think of 1 possibility: using the CRMSvcUtil tool.

    Go to <CRM SDK>\SampleCode\CS\CrmSvcUtilExtensions\GeneratePicklistEnums, open the solution and change the FilteringService.cs file:

            public bool GenerateOptionSet(
                OptionSetMetadataBase optionSetMetadata, IServiceProvider services)
                if (optionSetMetadata.OptionSetType == OptionSetType.State || optionSetMetadata.OptionSetType == OptionSetType.Status)
                    return true;
                return false;

    Build the solution and go to <CRM SDK>\SampleCode\CS\CrmSvcUtilExtensions\GeneratePicklistEnums\bin\Debug
    Open the GenerateOptionSets.bat file in a text editor and change the lines:

    /url:<organizationservice url> (CRM->Settings->Solutions->Developer Resources) ^

    Add a PAUSE statement to the end of the bat file. If you run the bat file, you'll get a c# file with the enums of the state and status codes of all entities in your organization. Example:

    public enum lead_statuscode
    	New = 1,
    	Contacted = 2,
    	Qualified = 3,
    	Lost = 4,
    	CannotContact = 5,
    	NoLongerInterested = 6,
    	Canceled = 7,

    Hope this helps,

    Kind regards

    • Marked as answer by TJN11 Wednesday, March 25, 2015 7:41 PM
    Wednesday, March 25, 2015 8:21 AM