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

Power Automate中Adaptive Card处理Microsoft Forms选择字段报错求助

解决Power Automate推送Teams自适应卡片时Forms多选字段的解析错误

问题根源

Microsoft Forms的多选字段返回的响应是字符串化的JSON数组(如示例中的id3字段值"[\"iOS\"]"),直接将该值插入Adaptive Card的text属性时,会破坏卡片的JSON结构,导致Teams解析时抛出JsonReaderException。

解决方案

方法1:将字符串数组转为纯文本(推荐)

使用Power Automate内置函数先解析字符串为数组,再拼接为逗号分隔的文本:

  • 替换Adaptive Card中操作系统字段的表达式:
    原表达式:@{outputs('Get_response_details')?['body/id#']}
    替换为:@{join(json(outputs('Get_response_details')?['body/id3']), ', ')}

修改后的完整Adaptive Card JSON

{
  "type": "AdaptiveCard",
  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
  "version": "1.2",
  "body": [
    {"type": "TextBlock","text": "Title","size": "large","weight": "bolder","wrap": true},
    {"type": "TextBlock","text": "@{outputs('Get_response_details')?['body/id1']}","wrap": true},
    {"type": "TextBlock","text": "Description","size": "large","weight": "bolder","wrap": true},
    {"type": "TextBlock","text": "@{outputs('Get_response_details')?['body/id2']}","wrap": true},
    {"type": "TextBlock","text": "Operating System","size": "large","weight": "bolder","wrap": true},
    {"type": "TextBlock","text": "@{join(json(outputs('Get_response_details')?['body/id3']), ', ')}","wrap": true}
  ]
}

方法2:用列表样式展示多选结果(可选)

如果需要更清晰的列表展示,可使用Adaptive Card的FactSet组件:

{
  "type": "AdaptiveCard",
  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
  "version": "1.2",
  "body": [
    {"type": "TextBlock","text": "Title","size": "large","weight": "bolder","wrap": true},
    {"type": "TextBlock","text": "@{outputs('Get_response_details')?['body/id1']}","wrap": true},
    {"type": "TextBlock","text": "Description","size": "large","weight": "bolder","wrap": true},
    {"type": "TextBlock","text": "@{outputs('Get_response_details')?['body/id2']}","wrap": true},
    {"type": "TextBlock","text": "Operating System","size": "large","weight": "bolder","wrap": true},
    {
      "type": "FactSet",
      "facts": [
        {
          "title": "",
          "value": "@{join(json(outputs('Get_response_details')?['body/id3']), '\n')}"
        }
      ]
    }
  ]
}

验证方式

提交表单时选择多个操作系统选项(如Both),检查Teams中推送的自适应卡片是否正常显示所有选中项,无解析报错。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.13 05:46:05