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!
Let’s see how we can retrieve the Global Option Sets from your D365 instance –
- 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.
- Now, in the Invoke HTTP Request with Azure AD, use the below to query the GlobalOptionSetDefinitions
- 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 –
- 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 –
- 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
- Now, in Select, we’ll select the Value part of the Body of the HTTP Request we’ve used above.
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
- 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
- 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.
- 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 –
- Primary Key of Activity type entity in a Dataverse connector in Power Automate | Quick Tip
- Split On in Power Automate in SharePoint trigger for Item updates
- Search Rows (preview) Action in Dataverse connector in a Flow | Power Automate
- Suppress Workflow Header Information while sending back HTTP Response in a Flow | Power Automate
- Invalid XML issue in Dataverse connector for List Rows action | Fetch XML Query | Power Automate
- FetchXML Aggregation in a Flow using CDS (Current Environment) connector | Power Automate
- Invalid type. Expected Integer but got Number error in Parse JSON – Error at runtime after generating Schema | Power Automate
- Asynchronous HTTP Response from a Flow | Power Automate
- Converting JSON to XML and XML to JSON in a Flow | Power Automate
- FormatDateTime function in a Flow | Power Automate