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

Make.com/Integromat:如何在N个Bundle中迭代且不生成N个操作

在Make.com/Integromat中实现发票数据的扁平化转换(固定操作数)

问题场景

调用API后得到以下格式的Bundle数据(实际数量更多):

Bundle 1 :

{ 
    "InvoiceId" : 1111,
    "InvoiceElements" : [
        { "Id":1, "Description" : "Fish" , "Price" : 10}, 
        { "Id":2,"Description" : "Meat" , "Price" : 30},
        { "Id":3,"Description" : "Tomato" , "Price" : 4}
    ]
}  

Bundle 2 :

{ 
    "InvoiceId" : 1112,
    "InvoiceElements" : [
        { "Id":1, "Description" : "Fish" , "Price" : 10}, 
        { "Id":2,"Description" : "Meat" , "Price" : 30}
    ]
}

需要将其转换为以下格式的数组(或拆分为对应数量的Bundle),且不需要根据发票数量N生成N个操作:

[
    { "InvoiceId" : 1111, "Id":1, "Description" : "Fish" , "Price" : 10}, 
    { "InvoiceId" : 1111, "Id":2, "Description" : "Meat" , "Price" : 30},
    { "InvoiceId" : 1111, "Id":3, "Description" : "Tomato" , "Price" : 4},
    { "InvoiceId" : 1112, "Id":1, "Description" : "Fish" , "Price" : 10}, 
    { "InvoiceId" : 1112, "Id":2, "Description" : "Meat" , "Price" : 30}
]

(注:原期望输出中重复的InvoiceId字段为笔误,这里保留合理的单字段格式;若需保留重复字段,后续步骤可直接添加)

解决方案

可以通过4个固定模块实现,无论输入多少个发票Bundle,操作数都不变:

  • 步骤1:添加第一个Iterator模块
    选择遍历输入的所有发票Bundle,将每个单独的发票对象作为迭代输出。
  • 步骤2:添加第二个Iterator模块
    在第一个Iterator的内部,选择遍历当前发票对象的InvoiceElements数组,将每个商品元素作为迭代输出。
  • 步骤3:添加Transform JSON/Set Variables模块
    合并当前发票的InvoiceId和当前商品元素的所有字段,生成新的对象,示例JSON模板:
    {
      "InvoiceId": {{1.InvoiceId}},
      "Id": {{2.Id}},
      "Description": {{2.Description}},
      "Price": {{2.Price}}
    }
    
    若需要保留重复的InvoiceId字段,直接在模板里重复添加对应字段即可。
  • 步骤4:添加Aggregator/Split Array模块
    • 若需要输出为单个数组,用Aggregator模块收集所有合并后的对象,最终输出一个包含所有行的数组;
    • 若需要输出为对应数量的Bundle,用Split Array模块将聚合后的数组拆分为多个单独的Bundle。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.09 11:38:18