web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Copilot Studio / Conditional formatting...
Copilot Studio
Unanswered

Conditional formatting for adaptive cards

(0) ShareShare
ReportReport
Posted on by 69

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}" }]

 

Categories:
I have the same question (0)
  • Expiscornovus Profile Picture
    33,851 Most Valuable Professional on at

    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

     

  • NewUser22 Profile Picture
    69 on at

    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 Profile Picture
    33,851 Most Valuable Professional on at

    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

  • NewUser22 Profile Picture
    69 on at

    Here you go.

    NewUser22_0-1648051686215.png

     

  • Expiscornovus Profile Picture
    33,851 Most Valuable Professional on at

    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

  • NewUser22 Profile Picture
    69 on at

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

  • Expiscornovus Profile Picture
    33,851 Most Valuable Professional on at

    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

  • PulkitM Profile Picture
    24 on at

    Hi,

    Just want to know from where Month variable is getting value.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Copilot Studio

#1
Valantis Profile Picture

Valantis 671

#2
Vish WR Profile Picture

Vish WR 266

#3
Haque Profile Picture

Haque 265

Last 30 days Overall leaderboard