Retrieve Metadata of Global OptionSets from Dynamics 365 in Power Automate | HTTP with Azure AD action

Not sure if you’ll ever need to retrieve the Metadata of Global OptionSets ever or if you’re just curious that this could be retrieved or not, probably this post might be able to help. 😊

Let’s look at how you can retrieve Global Option Set metadata from your Dynamics 365 instance in Power Automate using Invoke and HTTP Request using Azure AD connector.
I’ve mentioned some considerations along the way as well!

Flow

Let’s see how we can retrieve the Global Option Sets from your D365 instance –

  1. For simplicity, my Flow will run on-demand. Hence, the next step is to have HTTP with Azure AD connector to be used.
    Consideration: The reason we are not using Dataverse connector is because it doesn’t let you Retrieve / Retrieve Multiple on GlobalOptionSetDefinitions which is required in this case.
    And you’ll be using HTTP Request to retrieve resources from your current D365 environment and hence, will use Connection Reference based on who can access the APIs.



  2. Now, in the Invoke HTTP Request with Azure AD, use the below to query the GlobalOptionSetDefinitions


  3. Further, once this is executed, the Output of the request will be a JSON response which is tremendously huge and detailed.
    So, when I format it in an online formatter, it looks something like this –


  4. Consideration: $filter= is not supported in this type Request. Hence, it won’t work and you’ll get the below error. Below is an example when I tried –




  5. So, after referring to #3 above
    Now, once you have retrieved this data, we’ll use Filter array action in Power Automate to filter the OptionSet Metadata based on the the Name of the OptionSet and select that piece of JSON which contains the details of 1 single Option Set

  6. Now, in Select, we’ll select the Value part of the Body of the HTTP Request we’ve used above.
    body(‘Invoke_an_HTTP_request’)?[‘value’]
    And the reason we select value is because from the Body of the step above, we are selecting the Value array which is an Option Set record itself.
    Further, we’ll use a criteria to Filter the same.


    And if you Peek Code this and see


  7. Next, the criteria we’ll use to filter is based on the name of the Option Set itself which you can easily see in Dynamics 365.
    We’ll pick item()[‘Name’] to select the JSON attribute whose value we want to compare on the right hand side


    And if you Peek Code here

  8. Now, the reason we chose this is in #3 above, if you expand, you’ll see the Name JSON attribute that contains your Unique Name of the OptionSet.


  9. And now, when you Run the Flow and see the Result of the last Filter Array Step


    And if you take these Outputs and Beautify to see the structure, you’ll see that this is 1 Option Set’s Metadata. You can then see these values if you ever need to retrieve the Global Option Sets at any point.

Here are some more Power Automate / Flow posts you might want to check –

  1. Primary Key of Activity type entity in a Dataverse connector in Power Automate | Quick Tip
  2. Split On in Power Automate in SharePoint trigger for Item updates
  3. Search Rows (preview) Action in Dataverse connector in a Flow | Power Automate
  4. Suppress Workflow Header Information while sending back HTTP Response in a Flow | Power Automate
  5. Invalid XML issue in Dataverse connector for List Rows action | Fetch XML Query | Power Automate
  6. FetchXML Aggregation in a Flow using CDS (Current Environment) connector | Power Automate
  7. Invalid type. Expected Integer but got Number error in Parse JSON – Error at runtime after generating Schema | Power Automate
  8. Asynchronous HTTP Response from a Flow | Power Automate
  9. Converting JSON to XML and XML to JSON in a Flow | Power Automate
  10. FormatDateTime function in a Flow | Power Automate

Thank you!

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.