PowerAutomate Adaptive Cards - Input.Choice set from dynamic list/array

28 Views Asked by At

I am in the early stages of learning adaptive cards. I have an array filled with names/email addresses that is read from a sharepoint member list. I am attempting to display this list as an assignment field in an adaptive card.

I have been able to make the card work with hardcoded values for the title/value.

"actions": [
    {
        "type": "Action.ShowCard",
        "title": "Assign Request",
        "card": {
            "type": "AdaptiveCard",
            "body": [
                {
                    "type": "Input.ChoiceSet",
                    "id": "AssignedMember",
                    "choices": [
                        {
                            "title": "Paul Smith",
                            "value": "[email protected]"
                        },
                        {
                            "title": "Mike Jones",
                            "value": "[email protected]"
                        }
                    ],
                    "errorMessage": "This is a required input",
                    "placeholder": "Please Choose",
                    "isRequired": true
                }
            ],
            "actions": [
                {
                    "type": "Action.Submit",
                    "title": "OK"
                }
            ],
            "$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
        }
    },

Array Values: 

[
  {
    "@odata.type": "#microsoft.graph.user",
    "id": "a9b4ab8dfd78",
    "displayName": "Paul Smith",
    "mail": "[email protected]",
  },
  {
    "@odata.type": "#microsoft.graph.user",
    "id": "b94bbcb08f",
    "displayName": "Mike Jones",
    "mail": "[email protected]",
  {
    "@odata.type": "#microsoft.graph.user",
    "id": "96d9c39e6b",
    "displayName": "Todd Neal",
    "mail": "[email protected]",

  }
]


1

There are 1 best solutions below

0
Skin On BEST ANSWER

Use a Select action from the Data operations connector.

Sample Flow

Sample Flow

From = This is just the sample list of users you provided.

With the next two fields, I just used what I felt worked, you can pick email or whatever.

title = item()['id']

value = item()['displayName']

Result

[
  {
    "title": "a9b4ab8dfd78",
    "value": "Paul Smith"
  },
  {
    "title": "b94bbcb08f",
    "value": "Mike Jones"
  },
  {
    "title": "96d9c39e6b",
    "value": "Todd Neal"
  }
]

Result

Then just inject the output of the Select into the choices array property in the adaptive card JSON.