基于Adaptive Card选项集值切换容器可见性问题排查
Adaptive Card 日期容器可见性切换问题解决方法
你遇到的问题是Adaptive Cards可见性逻辑的表达式写法不符合规范,以下是修正方案及错误原因说明:
错误原因分析
- 错误引用
triggerOutputs:卡片内部控件的交互逻辑无需使用triggerOutputs,直接通过控件ID(feature_choice)引用其值即可。 - 错误使用
conditions属性:Adaptive Cards中不存在conditions这个控制可见性的属性,容器类元素的可见性控制应使用when属性。 contains表达式不适用:此处需要精确匹配选项值,contains是包含匹配逻辑,不符合需求。when属性表达式格式错误:你当前的${feature_choice.value == 'Date Wise Leave'}不是Adaptive Expression Language(AEL)的正确写法。
正确代码实现
将date_selection_container的when属性修改为AEL的精确匹配表达式即可:
{ "type": "Input.ChoiceSet", "id": "feature_choice", "label": "Which type of leave information you needed?", "placeholder": "Please Select the feature type", "value": "Monthly Leave", "choices": [ { "title": "Monthly Leave", "value": "Monthly Leave" }, { "title": "Date Wise Leave", "value": "Date Wise Leave" }, { "title": "Recent 5 Leave", "value": "Recent 5 Leave" } ], "isRequired": true, "wrap": true, "separator": true }, { "type": "Container", "id": "date_selection_container", "padding": "None", "when": "=equals(feature_choice.value, 'Date Wise Leave')", "items": [ { "type": "Input.Date", "label": "From", "id": "start_date_input" }, { "type": "Input.Date", "label": "To", "id": "end_date_input", "value": "2023-04-27" } ] }
额外注意事项
- 确保你的Adaptive Cards版本在v1.2及以上(
when属性从v1.2开始支持)。 - 确认宿主环境(如Teams、Power Automate、Power Apps等)支持Adaptive Expression Language语法。
内容的提问来源于stack exchange,提问作者Himanshu Rajput
相关产品推荐
相关产品推荐

