Skip to main content

Notifications

Power Automate - Connector Development
Suggested answer

Dynamic dropdowns in an array - how to reference adjacent field

(1) ShareShare
ReportReport
Posted on by 4
I'm building a custom connector that accepts an array of Country/State objects, where both state and country are dropdowns, and the state is parameterized by the specified country. 
 
In my OpenAPI, I have a LocationList definition that contains the array of Location items.  How can I define the parameter reference for the state field so that it uses the country of the current item in the array?  
 
The documentation for x-ms-dynamic-values and x-ms-dynamic-list describes how to reference other parameters in the request body (like body/country_id), but there doesn't seem to be a way to reference other properties within an array parameter?
 
In other words, how do I express the reference to the country_id parameter in the highlighted text below?
 
    "LocationList": {
      "type": "object",
      "description": "An object that describes the list of locations.",
      "properties": {
        "locations": {
          "type": "array",
          "description": "The list of locations.",
          "x-ms-summary": "Locations",
          "items": {
            "$ref": "#/definitions/Location"
          }
        }
      }
    },
    "Location": {
      "type": "object",
      "description": "An object that describes a location.",
      "required": [
        "country_id",
        "state_id"
      ],
      "properties": {
        "country_id": {
          "type": "string",
          "description": "The country.",
          "x-ms-summary": "country",
          "x-ms-dynamic-values": {
            "operationId": "ListCountries",
            "value-collection": "items",
            "value-path": "id",
            "value-title": "name"
          },
          "x-ms-dynamic-list": {
            "operationId": "ListCountries",
            "itemsPath": "items",
            "itemValuePath": "id",
            "itemTitlePath": "name"
          }
        },
        "state_id": {
          "type": "string",
          "description": "The state within the specified country.",
          "x-ms-summary": "state",
          "x-ms-dynamic-values": {
            "operationId": "LoadStates",
            "value-collection": "items",
            "value-path": "id",
            "value-title": "name",
            "parameters": {
              "country_id": {
                "parameter": "HOW DO I REFERENCE THE COUNTRY_ID PARAMETER HERE?"
              }
            }
          },
          "x-ms-dynamic-list": {
            "operationId": "LoadStates",
            "itemsPath": "items",
            "itemValuePath": "id",
            "itemTitlePath": "name",
            "parameters": {
              "country_id": {
                "parameterReference": "HOW DO I REFERENCE THE COUNTRY_ID PARAMETER HERE?"
              }
            }
          }
        }
      }
    },
Categories:
  • Ben Lambert Profile Picture
    Ben Lambert 4 on at
    Dynamic dropdowns in an array - how to reference adjacent field
    Thanks for the reply Tom, but I don't think that works (I get the standard error "The parameter could not be found in the operation" when trying to update the connector).  I've never seen that $. notation in the OpenAPI for any connector - do you have any docs or examples of that working?
  • Suggested answer
    trice602 Profile Picture
    trice602 11,772 on at
    Dynamic dropdowns in an array - how to reference adjacent field
    Hi,
     
    Please try in portion in your code:
     
    "parameters": {
       "country_id": {
          "parameter": "$.country_id" // Reference to country_id
        }
    }
     
     
    ------------------------------------------------


    If this was helpful, please like and/or mark as a verified answer to help others find this too!


    Always glad to help! 💯💯💯💯💯

    Tom 

    Follow me on LinkedIn - Thomas Rice, PMP | LinkedIn

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,508

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,839

Leaderboard

Featured topics