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

如何强制Power Automate的Select操作输出整数类型

解决Power Automate Select操作字段类型变为字符串的问题

针对你遇到的Select操作中OrderedSalesQuantity和SalesPrice字段从整数变为字符串、且int()强制转换无效的问题,可尝试以下几种方案:

方案1:在Select前先完成字段类型转换

  1. 在Select步骤前添加Apply to each操作,遍历原数组
  2. 在内层添加Compose操作,输入表达式完成类型转换:
    {
      "OrderedSalesQuantity": int(item()?['OrderedSalesQuantity']),
      "SalesPrice": int(item()?['SalesPrice']),
      // 保留原数组其他需要的字段
      "OtherField": item()?['OtherField']
    }
    
  3. 将Apply to each的输出作为Select操作的数据源,直接映射Compose中的对应字段即可

方案2:用Parse JSON强制指定字段类型

  1. 在Select步骤后添加Parse JSON操作
  2. 点击“生成示例”,输入包含整数类型目标字段的JSON示例,生成Schema
    示例JSON参考:
    [
      {
        "OrderedSalesQuantity": 10,
        "SalesPrice": 200,
        "NewField1": "value1",
        "NewField2": "value2"
      }
    ]
    
  3. 生成的Schema中这两个字段会被定义为"type": "integer",后续流程使用Parse JSON的输出即可确保类型正确

方案3:检查Select映射的表达式细节

确认Select中映射字段时的表达式是否正确,避免隐性字符串转换:

  • 确保表达式没有被额外的引号包裹,正确写法:
    int(item()?['OrderedSalesQuantity'])
    
    错误写法(会强制转为字符串):
    '@{int(item()?['OrderedSalesQuantity'])}'
    
  • 检查原数组字段的原始类型,确认数据源未在新增字段后发生隐性变更

附你提供的操作截图:
Power Automate截图
截图说明

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.30 09:35:12