locked
How to retrieve all labels and values in an OptionSet on an Entity RRS feed

  • Question

  • I have an entity with an OptionSet.  I want to retrieve a collection of these items (Label, Value).
    Thursday, November 3, 2011 3:55 AM

All replies

  • Hi buddy,

    You need to use the metadata webservice or sdk.

    Here is sample from sdk. \sdk\samplecode\cs\metadata\attributes.

    RetrieveAttributeRequest

     

    retrieveAttributeRequest =

     

    new

    RetrieveAttributeRequest

    {

    EntityLogicalName =

    Contact

    .EntityLogicalName,

    LogicalName =

    "new_picklist"

    ,

    RetrieveAsIfPublished =

    true

    };

     

    // Execute the request.

     

    RetrieveAttributeResponse

    retrieveAttributeResponse =

    (

    RetrieveAttributeResponse

    )_serviceProxy.Execute(

    retrieveAttributeRequest);

     

    // Access the retrieved attribute.

     

    PicklistAttributeMetadata

    retrievedPicklistAttributeMetadata =

    (

    PicklistAttributeMetadata

    )

    retrieveAttributeResponse.AttributeMetadata;

     

    // Get the current options list for the retrieved attribute.

     

    OptionMetadata

    [] optionList =

    retrievedPicklistAttributeMetadata.OptionSet.Options.ToArray();

    I hope this helps.


    Amreek Singh Senior CRM Consultant CDC Praxa Sydney, Australia http://mscrmshop.blogspot.com http://crm2011usersettings.codeplex.com
    • Proposed as answer by Amreek Singh Thursday, November 3, 2011 4:14 AM
    Thursday, November 3, 2011 4:13 AM