cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
New Member

Using policy template to convert an array of strings to an array of JSON objects for dynamic values dropdown

I am building a custom connector, and have an API with an operation that returns a JSON object with a string array property named "values".  I'd like to use the strings returned in the array to populate an x-ms-dynamic-values dropdown, but Flow requires an array of JSON objects rather than an array of strings.

 

Can I use any of the (recently introduced) connector policy templates to transform the string array into an array of JSON objects in the Response, so that I use this endpoint in my connector's API as the source for a dynamic values dropdown?

https://docs.microsoft.com/en-us/connectors/custom-connectors/policy-templates  

 

For example, my API returns a JSON object like this:

{ 
  "count": 3, 
  "values": [ 
    "Red", 
    "Green", 
    "Blue" 
  ] 
} 

...and I'd like to apply a connector policy to the Response from my API to transform the JSON into something like this:  

{ 
  "count": 3, 
  "values": [ 
    {"color": "Red"}, 
    {"color": "Green"}, 
    {"color": "Blue"} 
  ] 
}

...so that I can define a dynamic values dropdown in my connector like this:    

"x-ms-dynamic-values": {
  "operationId": "ListColors", 
  "value-collection": "values",
  "value-path": "color", 
  "value-title": "color" 
} 

Is that possible?  I see the docs for the new Preview connector policy templates that convert arrays to objects, but don't see any good reference examples.  

2 REPLIES 2
Helper III
Helper III

Thanks for the response, I but I think my scenario is different - I don't need a dynamic dropdown in an array, I need to use an array of strings as a dynamic dropdown (so I need to either update my API to emit an array of JSON objects, or if possible leverage a connector policy template to transform the response from my API from an array of strings to an array of JSON objects)

Helpful resources

Announcements
Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

Microsoft Ignite

Microsoft Power Platform: 2021 Release Wave 1 Plan

Power Platform release plan for the 2021 release wave 1 describes all new features releasing from April through September 2021.

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Users online (88,255)