how to get statuscode description? RRS feed

  • Question

  • Hello, I've defined some custom statuscodes for my incident entity.  When I set a breakpoint, I get the new statuscode, as expected.  However, I need to get the option text description for the status code.

    So say I've defined "Repro"/5 as a Resolved status code option. In my plugin code, I set a breakpoint and get incident.StatusCode of 5 as expected.  What's the easiest way for me to get the StatusCode description of "Repro" for that specific statuscode, at that point?
    Thursday, November 14, 2013 12:37 AM

All replies

  • Hello,

    Please re-check following thread.


    Hope this helps. If you get answer of your question, please mark the response as an answer and vote as helpful !
    Vikram !

    Thursday, November 14, 2013 1:58 AM
  • Hello

    I tried to get the Text values of PickList using both the above methods and both worked for me:

    1. using Retrieve method, i created a method for this (took help of one internet link). Paste this method and call it with input parameters to get the string value of picklist.

    private string GetOptionsSetTextOnValue(IOrganizationService service, string entityName, string attributeName, int selectedValue)
     RetrieveAttributeRequest retrieveAttributeRequest = new RetrieveAttributeRequest { EntityLogicalName = entityName, LogicalName = attributeName, RetrieveAsIfPublished = true };
      RetrieveAttributeResponse retrieveAttributeResponse = (RetrieveAttributeResponse)service.Execute(retrieveAttributeRequest);
      PicklistAttributeMetadata retrievedPicklistAttributeMetadata = (PicklistAttributeMetadata) retrieveAttributeResponse.AttributeMetadata;
      OptionMetadata [] optionList = retrievedPicklistAttributeMetadata.OptionSet.Options.ToArray();
      string selectedOptionLabel = string .Empty; 
      foreach (OptionMetadata oMD in optionList) 
       if (oMD.Value == selectedValue) 
        selectedOptionLabel = oMD.Label.UserLocalizedLabel.Label;
      return selectedOptionLabel; 
     catch (System.ServiceModel.FaultException ex1) 
      string strEr = ex1.InnerException.Data.ToString(); 
      return null; 

    2. Using LinQ:

    using System.Linq; // add this namespace 
    using (OrganizationServiceContext orgSvcContext = new OrganizationServiceContext (service))
     var query1 = from c in orgSvcContext.CreateQuery<ENTITY_NAME>() 
       where c["crm attribute1 in lower case"].Equals("value in string")
       && c["crm attribute2 in lower case"].Equals("value in string")
       && c["crm attribute3 in lower case"].Equals("value in string")
      select new 
       picklistStringValue = c.FormattedValues["picklist crm attribtue in lower case"] // formattedValues to get label string name
     foreach (var q in query1) 
      string strPicklistStringValue = q.picklistStringValue.ToString();

    Thursday, November 14, 2013 8:12 AM
  • you can check different optionset values available in a particular entity running the below SQL.

    SELECT * FROM FilteredStringMap
    WHERE FilteredViewName='FilteredIncident'

    Friday, November 15, 2013 3:20 PM