You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Microsoft Teams桌面/Web端自适应卡片ChoiceSet选中后错误未清除且无法提交

Teams自适应卡片ChoiceSet组件提交异常问题解决办法

问题现象

我开发的Microsoft Teams应用使用了自适应卡片,其中包含ChoiceSet组件:

  • 未选择任何选项时,提交操作能正确触发必填错误提示
  • 选择选项后,错误提示仍不消失,且提交功能完全失效
  • 该问题仅出现在Teams桌面端和Web端,移动端及Adaptive Card Designer中表现正常

原卡片Payload

{
  "type": "AdaptiveCard",
  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
  "version": "1.4",
  "body": [
    {
      "type": "Container",
      "verticalContentAlignment": "Top",
      "items": [
        {
          "type": "TextBlock",
          "text": "You have a new notification:\n\n*[ testing 123 : Approval ](https://app.example.com)*",
          "wrap": true
        },
        {
          "type": "FactSet",
          "facts": [
            {
              "title": "Requester",
              "value": "[teams-app review](mailto:abc@example.com)"
            },
            {
              "title": "Title",
              "value": "testing 123"
            },
            {
              "title": "Supplier",
              "value": "MARK10"
            },
            {
              "title": "Region",
              "value": "United States"
            },
            {
              "title": "Business entity",
              "value": "Teams-testing"
            },
            {
              "title": "Summary",
              "value": "qwerty hi"
            }
          ]
        },
        {
          "type": "ActionSet",
          "actions": [
            {
              "type": "Action.ShowCard",
              "title": "Request more info",
              "card": {
                "type": "AdaptiveCard",
                "body": [
                  {
                    "type": "Input.ChoiceSet",
                    "choices": [
                      {
                        "title": "teams-app review (Requester)",
                        "value": "{\"name\":\"teams-app review\",\"userName\":\"teams-app-review\",\"department\":\"Requester\"}"
                      }
                    ],
                    "placeholder": "choose one ore more participants",
                    "id": "rmi.participant",
                    "isMultiSelect": true,
                    "wrap": true,
                    "isRequired": true,
                    "errorMessage": "Please choose one or more participants",
                    "label": "From"
                  },
                  {
                    "type": "Input.Text",
                    "placeholder": "enter your request here...",
                    "isMultiline": true,
                    "maxLength": 250,
                    "isRequired": true,
                    "label": "Request",
                    "id": "rmi.request",
                    "errorMessage": "Please enter your request"
                  },
                  {
                    "type": "ActionSet",
                    "actions": [
                      {
                        "type": "Action.Submit",
                        "title": "Submit",
                        "id": "RMI.Submit",
                        "data": {
                          "processContext": {
                            "taskId": "336507284123746331",
                            "discussionId": null,
                            "emailId": "admin@M365x90692327.onmicrosoft.com",
                            "username": "teams-app-review",
                            "name": "teams-app review",
                            "tenantId": "teams_testing",
                            "engagementId": "336507052528379775"
                          },
                          "triggerActionType": "TASK_REQUEST_MORE_INFO"
                        }
                      }
                    ]
                  }
                ]
              },
              "id": "RMI_ACTION"
            }
          ]
        }
      ],
      "bleed": true,
      "spacing": "Small"
    }
  ]
}

问题根因

Teams桌面端和Web端的自适应卡片解析器,对ChoiceSet选项中包含嵌套JSON字符串的value值处理存在兼容性问题:即使用户选择了选项,解析器仍会错误判定该输入未满足必填条件,导致错误提示无法消失,提交操作被拦截。

解决方案

方案1:替换嵌套JSON格式的value值

将ChoiceSet选项的value改为无嵌套引号的简单格式(比如用分隔符拼接字符串),避免解析器出现校验异常。

修改后的ChoiceSet组件示例:

{
  "type": "Input.ChoiceSet",
  "choices": [
    {
      "title": "teams-app review (Requester)",
      "value": "teams-app-review|teams-app review|Requester"
    }
  ],
  "placeholder": "choose one or more participants",
  "id": "rmi.participant",
  "isMultiSelect": true,
  "wrap": true,
  "isRequired": true,
  "errorMessage": "Please choose one or more participants",
  "label": "From"
}

后端接收提交数据时,按分隔符(如|)拆分value字符串,即可还原出所需的结构化数据。

方案2:升级自适应卡片版本

将卡片的version字段从1.4升级到最新稳定版(如1.5),部分旧版本的解析bug已在新版本中修复。

方案3:对JSON字符串进行二次转义

如果必须保留JSON格式的value,可对其进行二次转义,确保解析器能正确识别:

{
  "title": "teams-app review (Requester)",
  "value": "{\\\"name\\\":\\\"teams-app review\\\",\\\"userName\\\":\\\"teams-app-review\\\",\\\"department\\\":\\\"Requester\\\"}"
}

内容的提问来源于stack exchange,提问作者user22345899

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.14 05:40:56