Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
xiaolufei opened this issue Jan 6, 2025 · 4 comments

Comments

@xiaolufei
Copy link

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

<title>Adaptive Card with Expressions</title>

Adaptive Card with Dynamic Expression

<script src="https://unpkg.com/[email protected]/dist/adaptivecards.min.js"></script> <script src="https://unpkg.com/adaptivecards-templating/dist/adaptivecards-templating.min.js"></script> <script> // 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}};
// Use adaptive-expressions to evaluate expressions in the template
const template = new AdaptiveCards.AdaptiveCard();
const card = new ACData.Template(cardTemplate);
// Expand the template with the dynamic data
const cardPayload = card.expand({ $root: dynamicData });
// Parse and render the adaptive card
template.parse(cardPayload);
document.getElementById("adaptiveCardDiv").appendChild(template.render());
</script>
@Nivedipa-MSFT
Copy link

@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?

@xiaolufei
Copy link
Author

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

@Nivedipa-MSFT
Copy link

@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!

@xiaolufei
Copy link
Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants