cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
NewUser22
Helper I
Helper I

Conditional formatting for adaptive cards

Hi all!

 

Wanted to check on how do we do conditional formatting for color on adaptive cards for bot composer? 

Seems like bot composer only supports version 1.3.

 

{
"type": "AdaptiveCard",
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.3",
"body": [
    {            
          "$data": "${AttendanceMonthly}",
          "type": "TextBlock",
          "weight": "bolder",
          "color": "${if(Month = January, 'attention', 'good')}",          
"text": "Hours worked: ${Month}" }]

 

7 REPLIES 7
Expiscornovus
Super User
Super User

Hi @NewUser22,

 

You could use an adaptive expression which uses the if and equals functions.

 

Below is an example which should work with 1.3 (I have tested it in the Demo website channel)

${if(equals(Month,January), 'Attention', 'Good')}

 

1. The code on the bot framework composer

adaptiveexpression_formatting.png

 

2. The testing in the Demo website channel.

 

hoursworkedcolorgood.png

 



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


That's great! Did it work for your second case though? I find that mine still stuck at "good" even if it is not january.

 

{
"type": "AdaptiveCard",
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.3",
"body": [
    {            
          "$data": "${AttendanceMonthly}",
          "type": "TextBlock",
          "weight": "bolder",
          "color": "${if(equals(Month,Jan), 'good', 'attention')}",          
"text": "Hours worked: ${Month}" }],  

 

Also tried it on designer io but still not working for me.

 

NewUser22_0-1648048363747.png

 

Expiscornovus
Super User
Super User

Hi @NewUser22,

 

Yes, it also worked for the valueIfFalse, see the gif below. 

 

I am outputting March in the Month property and therefore it is showing the valueIfFalse. Which in this new setup is Attention (aka the red color), just like in your expression.

 

What are you outputting in Month? Can you share a screenshot of a test run in the Demo website channel?

 

Attention_March.gif



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


Here you go.

NewUser22_0-1648051686215.png

 

Expiscornovus
Super User
Super User

Hi @NewUser22,

 

Thanks for sharing, but I see that is a screenshot from https://adaptivecards.io/designer/

 

Apologies that I was not clear, I am talking about testing it from the Demo website channel within your Power Virtual Agent 😀

 

demo_website.png



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


Oh i see! Thanks for clarifying. Does it work for teams in your case? We are using the PVA in teams. 

Expiscornovus
Super User
Super User

Hi @NewUser22,

 

It looks like the adaptive card designer website does not like our expressions 😁

 

adaptivecarddesigner.png

 

But it seems to work fine in PVA in teams (in the browser, I have not tried the Teams Desktop client).

 

Attention_March_PVATeams.gif



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Virtual Agents Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Virtual Agents!

Users online (2,059)