AdaptiveCards icon indicating copy to clipboard operation
AdaptiveCards copied to clipboard

[Bug]Error in AdaptiveCards Templating SDK: Cannot Read Properties of Undefined ('Expression')

Open xiaolufei opened this issue 1 year ago • 9 comments

Target Platforms

Other

SDK Version

2.3.1

Application Name

adaptivecards-templating

Problem Description

I encountered an issue where properties in the JavaScript version of the AdaptiveCards Templating SDK are undefined. How can I resolve this issue?issue-adaptive-cards-sdk.docx

Screenshots

Image

Image

Card JSON

// Define the Adaptive Card template
    const cardTemplate = {"type":"AdaptiveCard","version":"1.0",
        "body":[
            {"type":"TextBlock","text":"Hello ${name}!"},
            {"type":"TextBlock","text":"=if(age >= 18, 'You are an adult.', 'You are a minor.')"}]};
    // Define dynamic data (this could come from an API or user input)
    const dynamicData = {"$root":{"name":"John","age":25}};

Sample Code Language

JS

Sample Code

Adaptive Card with Expressions

Adaptive Card with Dynamic Expression

xiaolufei avatar Jan 06 '25 02:01 xiaolufei

@xiaolufei - Thank you for bringing this issue to our attention. Can you confirm whether you plan to display this adaptive card on the Teams platform?

Nivedipa-MSFT avatar Jan 06 '25 08:01 Nivedipa-MSFT

@Nivedipa-MSFT Yes, I plan to display this adaptive card on the Teams platform.

xiaolufei avatar Jan 08 '25 06:01 xiaolufei

@xiaolufei - Thanks for the confirmation. We were able to reproduce the issue. Image We have logged this as a bug, and our engineering team will look into it.

While we cannot guarantee a fix at this stage, we will keep you updated with any progress or changes. Please note that in some cases, the bug may be by design or deprioritized due to platform updates, but we will continue to monitor the bug closely.

Thank you again for your cooperation!

Nivedipa-MSFT avatar Jan 08 '25 18:01 Nivedipa-MSFT

@Nivedipa-MSFT I hope you can resolve this issue as soon as possible. Currently, this problem is blocking our work and causing our card data to fail to render.

xiaolufei avatar Jan 09 '25 03:01 xiaolufei

@Nivedipa-MSFT we are also getting same error and couldn't find any adaptive-expression CDN path. Tried with below but still same error

](https://cdn.jsdelivr.net/npm/[email protected]/dist/index.min.js%22%3E%3C/script%3E)

devanshuGit avatar Feb 12 '25 10:02 devanshuGit

@Nivedipa-MSFT any updates on this?

devanshuGit avatar Feb 20 '25 09:02 devanshuGit

I was having a similar error to the error above and so I tried to see if I can replicate above error. I was able to replicate the above error, whether or not I have the TextBlock with the dynamic expression in it. I belive the error is related to the following. In version 2.0 and later of adaptivecards-templating the adaptive-expressions package is not included. So when someone follows the docs and uses the script from CDN (version 2.0 or greater), it does not include adaptive-expressions and will always fail. If I changed that to use a version prior to 2.0 then the templating works, the card displays and I don't get the error. However, it still doesn't render the dynamic expression correctly. It displays the whole dynamic expression as text, rather than 'resolving' it.

Hopefully this helps shed some light on the issue

MrCodeWeaver avatar Feb 21 '25 19:02 MrCodeWeaver

Any progress on this one? I have the same problem.

Shaq76 avatar Mar 07 '25 13:03 Shaq76

Any updates ?

QaisAlkhateeb avatar Sep 14 '25 22:09 QaisAlkhateeb