Forum Discussion

Jake_Hembree's avatar
Jake_Hembree
Brass Contributor
Jun 02, 2023

Adaptive Card "Only Show When" based on string value containing

I have an adaptive card that I'm using in Power Automate. The source is from a SharePoint list that has a multiple choice field that can contain any combination of "Facebook", "Twitter", and/or "Instagram". 

 

The adaptive card has a section for each icon to appear based on if the "Platform" value contains the corresponding value (e.g., Facebook icon appears if the Platform value contains "Facebook").  

I can't seen to get the syntax correctly so that the icon only appears when the value contains the correct platform. With my current coding, the icons appear regardless of the value. Any thoughts?

See attached image.
But the current code is:

"items": [
{
     "type": "Image",
     "size": "Small",
     "spacing": "None",
     "url": "https://i.imgur.com/FM5R4eW.png",
     "id": "Instagram_Image",

     "$when": "$contains(\"@{body('Join_PLATFORMS')}\",\"Instagram\")"
}

  • Jake_Hembree I answered my own question. I now realized that the show as condition of the adapter card is only based on other criteria in the card itself and not outside values from Power Automate. As a workaround, I created the conditions I needed and made an if statement that simply provides the link I want in that section of the JSON. I'm leaving this here just in case someone else had a question like this and needs help with a workaround.

     

     

     

  • Jake_Hembree's avatar
    Jake_Hembree
    Brass Contributor

    Jake_Hembree I answered my own question. I now realized that the show as condition of the adapter card is only based on other criteria in the card itself and not outside values from Power Automate. As a workaround, I created the conditions I needed and made an if statement that simply provides the link I want in that section of the JSON. I'm leaving this here just in case someone else had a question like this and needs help with a workaround.

     

     

     

Resources