question

kokuljose avatar image
2 Votes"
kokuljose asked PaulSmoothy-5916 edited

Can i edit Adaptive card Choices dynamically? If yes how?

I have an Input.ChoiceSet in my adative card. I want to edit the choices and may the number of choices reduced after editing. How can I edit the card and reduce the number of choices and change the choice values?

azure-bot-service
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

romungi-MSFT avatar image
3 Votes"
romungi-MSFT answered

@kokuljose I think editing of the choices is restricted for the choiceSet from the client side. You can try a different way to take the inputs like inputs with validation and restrict the number of choices to the ones that are only required and others as optional along with show cards.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

PaulSmoothy-5916 avatar image
0 Votes"
PaulSmoothy-5916 answered BaumJoelJ-8033 published

Hi K,

I'm not sure if this is what you were exactly asking for, but it may be tailored for your situation.

I wanted to make a dynamically created set of choices in an adaptive card and get a user response.

This is how I did it.

Loop through list items to get the data I wanted, then for each item verify that it is correct (for me I wanted to make sure I didn't collect any that had missing information so I checked for "null" value and if it was null then do nothing. If Flow found a value that should be included then append to a string variable code like this:
94949-image.png

Then after looping through all the values I used a Compose (substring(variable), 1) to remove the leading "," and that left me with valid JSON to insert into the choices section of the adaptive card.

Hope that helps, though you may already have figured it out.

Regards,
Paul



image.png (14.9 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

"Then after looping through all the values I used a Compose (substring(variable), 1) to remove the leading "," and that left me with valid JSON to insert into the choices section of the adaptive card."

Please give an example of the JSON code to do this part.

0 Votes 0 ·
PaulSmoothy-5916 avatar image
0 Votes"
PaulSmoothy-5916 answered PaulSmoothy-5916 edited

Not sure which part you mean @BaumJoelJ-8033 , but this is how I get a list of items
146680-image.png

Then this is how I use the variable in the JSON of a Teams adaptive card.
The output is from the Compose where the list of items from my previous post are collected, but the first "," stripped off to make it valid JSON.

Hope that helps.
146704-image.png



image.png (29.4 KiB)
image.png (5.9 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.