If you are new to Adaptive Cards, it may come across that Action.ShowCard and Action.ToggleVisibility seems to do the same thing.
But let’s look at the difference between the two!
|1||ShowCard||Shows or Hides a Card Structure enclosed on ShowCard Action|
|2||ToggleVisibility||Shows or Hides individual elements based on their IDs|
Below is JSON to understand the structure of how ShowCard Action exists and how it will function
- ShowCard is a standalone ‘Card’ within an Action Element CardAction.
- Now, let’s see how it works. When the Card is not shown, only the button will appear like any other Action button in AdaptiveCards.
And when you click on it, the Show Card action will reveal the Card that is structured under it.
Similarly, let’s look at how ToggleVisibility will work as opposed to Show Card.
- The JSON structure for ToggleVisibility in ActionSet is as follows –
Notice that the type: Action.ToggleVisibility
- Now, the “targetElements” in the above Action takes in array of Element IDs which should be toggled for Visibility.
Since, I’ve mentioned only 1 element in it whose ID is “createdDate“, below is how the element looks and where you can get the ID from –
- Now, when I click on the button, it’ll consider all the element IDs mentioned in the array to toggle between Show / Hide.
Before I click the button –
And when I click on the button, the visibility is toggled to show this time –
- So as opposed to ShowCard, ToggleVisibility will toggle Show/Hide functionality of selected elements and not a Card structure that resides inside a ShowCard Action.
Placing Action Elements – ShowCard and ToggleVisibility
- By default, if you select an Action from the Elements menu on the left hand side, they’ll end up in the shown hierarchy.
And the JSON for this will appear like this –
The type of Element which resides in Body of the AdaptiveCard itself
Zoomed Out, it’ll look like this –
- However, if you don’t wish to have it under an Action Set in the Body structure, you can place the type of Action whether it is ToggleVisibility or ShowCard in Actions section of the JSON as well.
And this will exist in the Actions of the AdaptiveCard JSON and not in the Body as shown above.
Here are some more posts related to Adaptive Cards / Microsoft Teams which you might find useful –
- Save Adaptive Cards work using VS Code Extension – Adaptive Cards Studio | Quick Tip
- Adaptive Cards for Outlook Actionable Messages using Power Automate | Power Platform
- Visualize Adaptive Card for Teams user action within a Cloud Flow | Experimental Feature
- Adaptive Cards for Teams to collect data from users using Power Automate | SharePoint Lists
- Admin Center URLs under M365 – Power Platform, Teams, SharePoint, Power BI
- Tag a User in a Microsoft Teams post made using Power Automate
- Asynchronous HTTP Response from a Flow | Power Automate
- Using outputs() function and JSON Parse to read data from missing dynamic value in a Flow | Power Automate