powerappsdynamics-365pcf

PCF control that shows list of OptionSets


I have this situation: I need to show a list of all OptionSets from Dynamics 365 on a PCF Component.

I've tried the "RetrieveMultiple" method on the "OptionSet" entity but I'm getting this error:

the 'retrievemultiple' method does not support entities of type 'optionset'

I dont know how I should get or even query data from this entity.

Thanks in advance.-


Solution

  • When you only need the global option sets, you can use the RetrieveAllOptionSetsRequest:

    C#

    var request = new RetrieveAllOptionSetsRequest();
    
    OptionSetMetadataBase[] optionSets = ((RetrieveAllOptionSetsResponse)_organizationService.Execute(request))
        .OptionSetMetadata;
    

    In JavaScript/TypeScript you can retrieve global optionsets by using this Web API:

    [Organization URI]/api/data/v9.0/GlobalOptionSetDefinitions
    

    Also see MS Docs - Use the Web API with table definitions.

    When you also need all other optionsets in the system, you need to get all entity metadata and from each entity you need to filter all optionset attributes not associated with global option sets.

    The entity metadata can be retrieved using the RetrieveAllEntitiesRequest.