question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Authoring] Expanding from template data doesn't work on arrays ($data: someArray)

See original GitHub issue

Target Application

Microsoft Teams

Application Operating System

Windows

Schema Version

1.3

Problem Description

Hello,

⚠️⚠️⚠️ LE: the issue was due to preview mode turned off, see next comment

I’ve tried using the designer and also the node package for templating (adaptivecards-templating) and both yield the same results.

I have a custom card in the works, but it looks like that not even the designer works.

When binding $data which contains an array the resulting renderer should repeat each item from that array with the corresponding data.

Even the basic example from the designer doesn’t work; I tried it on so many other devices, different browsers, they all don’t populate:

image

Also the JSON output (with the card payload) from the adaptivecards-templating node package doesn’t complete the placeholders

Expected Outcome

For each item in the array the data should be bound in the resulting render.

Actual Outcome

Only the placeholders are present like ${key}: ${value}.

Card JSON

//payload

{
    "type": "AdaptiveCard",
    "body": [
        {
            "type": "TextBlock",
            "size": "Medium",
            "weight": "Bolder",
            "text": "${title}"
        },
        {
            "type": "ColumnSet",
            "columns": [
                {
                    "type": "Column",
                    "items": [
                        {
                            "type": "Image",
                            "style": "Person",
                            "url": "${creator.profileImage}",
                            "size": "Small"
                        }
                    ],
                    "width": "auto"
                },
                {
                    "type": "Column",
                    "items": [
                        {
                            "type": "TextBlock",
                            "weight": "Bolder",
                            "text": "${creator.name}",
                            "wrap": true
                        },
                        {
                            "type": "TextBlock",
                            "spacing": "None",
                            "text": "Created {{DATE(${createdUtc},SHORT)}}",
                            "isSubtle": true,
                            "wrap": true
                        }
                    ],
                    "width": "stretch"
                }
            ]
        },
        {
            "type": "TextBlock",
            "text": "${description}",
            "wrap": true
        },
        {
            "type": "FactSet",
            "facts": [
                {
                    "$data": "${properties}",
                    "title": "${key}:",
                    "value": "${value}"
                }
            ]
        }
    ],
    "actions": [
        {
            "type": "Action.ShowCard",
            "title": "Set due date",
            "card": {
                "type": "AdaptiveCard",
                "body": [
                    {
                        "type": "Input.Date",
                        "id": "dueDate"
                    },
                    {
                        "type": "Input.Text",
                        "id": "comment",
                        "placeholder": "Add a comment",
                        "isMultiline": true
                    }
                ],
                "actions": [
                    {
                        "type": "Action.Submit",
                        "title": "OK"
                    }
                ],
                "$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
            }
        },
        {
            "type": "Action.OpenUrl",
            "title": "View",
            "url": "${viewUrl}"
        }
    ],
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.5"
}

//data

{
    "title": "Publish Adaptive Card Schema",
    "description": "Now that we have defined the main rules and features of the format, we need to produce a schema and publish it to GitHub. The schema will be the starting point of our reference documentation.",
    "creator": {
        "name": "Matt Hidinger",
        "profileImage": "https://pbs.twimg.com/profile_images/3647943215/d7f12830b3c17a5a9e4afcc370e3a37e_400x400.jpeg"
    },
    "createdUtc": "2017-02-14T06:08:39Z",
    "viewUrl": "https://adaptivecards.io",
    "properties": [
        {
            "key": "Board",
            "value": "Adaptive Cards"
        },
        {
            "key": "List",
            "value": "Backlog"
        },
        {
            "key": "Assigned to",
            "value": "Matt Hidinger"
        },
        {
            "key": "Due date",
            "value": "Not set"
        }
    ]
}

Repro Steps

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
JeanRocacommented, Jun 27, 2022

Looks like this issue has been resolved? Let us know if there’s anything we can do to help further. Thanks! @JeanRoca J.P. Roca FTE - it might be worth tracking investigating a UX improvement around template binding and needing to click the preview button…

So something that indicates one must be in preview mode before seeing templating changes, right?

Yes 😃 . I’ve checked the designer on multiple different devices and all of them had preview mode off so you’d see placeholders in the rendered card. Also there’s no visual cue to whether the preview mode is on or off

Preview mode defaulting to off is intended behavior. As far as visual cues we currently change the color of the button to indicate selection as shown here:

Preview Mode OFF: image

Preview Mode ON: image

I do think there is room for improvement though.

0reactions
JeanRocacommented, Jun 27, 2022

Looks like this issue has been resolved? Let us know if there’s anything we can do to help further. Thanks! @JeanRoca - it might be worth tracking investigating a UX improvement around template binding and needing to click the preview button…

Well the “issue” on my second comment. I was under the impression that $data from “level 1” would also be bound to the nested elements underneath it; so then I can reference it (eg: multi-dimensional arrays; for example, rendering an array of countries and each country contains 3 top cities by population)

I see now. Here is an example of how to achieve this:

Card Payload:

{
    "type": "AdaptiveCard",
    "body": [
        {
            "type": "FactSet",
            "$data": "${countries}",
            "facts": [
                {
                    "$data": "${take(topCities, 2)}",
                    "title": "City:",
                    "value": "${cityName}"
                }
            ]
        }
    ],
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.5"
}

Data Payload:

{
    "countries": [
        {
            "countryName": "Canada",
            "topCities": [
                {
                    "cityName": "Montreal",
                    "population": 1000
                },
                {
                    "cityName": "Vancouver",
                    "population": 2000
                }
            ]
        }
    ]
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Problems Expanding an Array in C++
I can run the program fine without reproduction (commenting out the calls to expandarray), but calling this function causes my program to crash....
Read more >
Help with load and save
Hi, I'm trying to create a load and save system. I followed Shaun's tutorial with structs . It works like it's supposed to...
Read more >
Array databases: concepts, standards, implementations
This article presents results of the Research Data Alliance (RDA) Array Database Assessment Working Group (ADA:WG), a subgroup of the Big Data ......
Read more >
Computation
DataArray objects automatically align themselves (“broadcasting” in the numpy parlance) by dimension name instead of axis order. With xarray, you do not need...
Read more >
Arrays (`Array`) • JavaScript for impatient programmers ...
JavaScript Arrays are a very flexible data structure and used as lists, stacks, queues, tuples (e.g. pairs), and more. Some Array-related operations ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found