Search code examples
adaptive-cards

Display number in adaptive card


I have the following simple card:

    {
        "type": "AdaptiveCard",
        "version": "1.0",
        "body": [
            {
                "type": "TextBlock",
                "text": "{data}"
            }
        ],
        "$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
    }

When I apply the following data to the card (value is number), the text box is empty:

{
"data":11111
}

With text, the I can see the data in the card:

{
"data":"11111"
}

This is not a code issue, this is how it looks in the designer. Am I missing something, is there a type for a text box that lets display numbers or is this by design and I have to change all numeric fields to text?


Solution

  • This is a limitation of the preview (known as Type Coercion) that we hope to address before release. As another workaround you can include a space after the binding expression which will force it into a string. See the below example, notice the space after {data}

    
       {
            "type": "AdaptiveCard",
            "version": "1.0",
            "body": [
                {
                    "type": "TextBlock",
                    "text": "{data} "
                }
            ],
            "$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
        }