{
  "elementsLearnedData": [],
  "elementsTestData": [],
  "flow": {
    "id": "50DF1E1E-4CB6-4DCE-B42D-2597760AEA75",
    "name": "Holded: warehouse dispatch to shipped order"
  },
  "flowVersion": {
    "clientMetadata": {
      "viewport": {
        "x": 227.29018286373991,
        "y": 26.94535109754736,
        "zoom": 0.5
      },
      "autoSave": true,
      "descriptions": {
        "flow": "Starts when your warehouse system posts a dispatch to this flow's URL. The dispatch is JSON: salesOrderId (the Holded sales order id), optional salesOrderNumber, trackingNumbers (or trackingNumber), carrierKey (for example seur, correos, mrw), carrierName, pickUpDate, lines (the lines shipped with the quantity of each, as Holded's ship by line route takes them; leave it out when the whole order shipped) and stockCorrections (each with productId, productName, warehouseId, warehouseName, stock as the corrected level, and reason).",
        "initialData": "",
        "initialDataFields": {}
      }
    },
    "description": "When the warehouse reports a dispatch, records tracking on the Holded sales order, marks lines shipped, moves a fully shipped order to the Shipped stage, and logs stock corrections to Google Sheets.",
    "elements": [
      {
        "clientMetadata": {
          "notes": "Reads how many units of each line of a Holded sales order have shipped.",
          "elementId": "EXTENSION:::SHARED:::default:::holded:::getShippedItems",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Read back what has shipped Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::holded:::getShippedItems",
          "legacyElementId": "JS###v1###HoldedService###getShippedItems",
          "methodName": "getShippedItems",
          "position": {
            "x": 564,
            "y": 840
          }
        },
        "flowElementId": "89F5F0F7-A862-43D0-ACF9-75DDAA131C9A",
        "groupId": null,
        "id": "FE77BB20-D600-4B43-9872-DB9140176A35",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "documentId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Dispatch details",
                    "subPathSegments": [
                      {
                        "key": "orderId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "71F52924-D0D8-40E5-8787-DDE1DA2B11D3"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "getShippedItems",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Shipped items",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "holded",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Read back what has shipped",
        "nextElementIds": [
          "A05BA37C-358C-4FB2-B266-1DDAFF162491"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Records shipment tracking details on a Holded sales order or waybill.",
          "elementId": "EXTENSION:::SHARED:::default:::holded:::updateDocumentTracking",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Record the tracking Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::holded:::updateDocumentTracking",
          "legacyElementId": "JS###v1###HoldedService###updateDocumentTracking",
          "methodName": "updateDocumentTracking",
          "position": {
            "x": 592,
            "y": 398
          }
        },
        "flowElementId": "EB4E7E2D-0824-44CE-B3D4-90DCFEE532EA",
        "groupId": null,
        "id": "D8FE6A2F-32FF-43AB-8F79-CD55F93F0FD3",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "documentId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Dispatch details",
                    "subPathSegments": [
                      {
                        "key": "orderId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "71F52924-D0D8-40E5-8787-DDE1DA2B11D3"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "trackingNumbers",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Dispatch details",
                    "subPathSegments": [
                      {
                        "key": "trackingNumbers",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "71F52924-D0D8-40E5-8787-DDE1DA2B11D3"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "documentType",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "salesorder"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "carrierKey",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Dispatch details",
                    "subPathSegments": [
                      {
                        "key": "carrierKey",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "71F52924-D0D8-40E5-8787-DDE1DA2B11D3"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "carrierName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Dispatch details",
                    "subPathSegments": [
                      {
                        "key": "carrierName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "71F52924-D0D8-40E5-8787-DDE1DA2B11D3"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "pickUpDate",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Dispatch details",
                    "subPathSegments": [
                      {
                        "key": "pickUpDate",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "71F52924-D0D8-40E5-8787-DDE1DA2B11D3"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "deliveryDate",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "notes",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "updateDocumentTracking",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Tracking",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "holded",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Record the tracking",
        "nextElementIds": [
          "EA1BE401-85D3-41F6-885D-78FB7FC98A7C"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "external-callback",
          "isFirstElement": true,
          "blockDefinitionId": "external-callback",
          "position": {
            "x": 110,
            "y": 220
          }
        },
        "flowElementId": "5FE9C4EE-546F-4CDE-A45C-04149CA0D1E1",
        "groupId": null,
        "id": "14B6EBFB-A453-4980-AD5D-54D967125E26",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": null,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": null
          },
          "onFailElemId": null,
          "resultAlias": "Dispatch",
          "slaConditions": [],
          "storeResult": true,
          "type": "CALLBACK"
        },
        "name": "Dispatch from the warehouse",
        "nextElementIds": [
          "71F52924-D0D8-40E5-8787-DDE1DA2B11D3"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "TRIGGER"
      },
      {
        "clientMetadata": {
          "notes": "Adds new data rows to Google Sheets for AI agents to store processed results, log user interactions, or collect data from automated workflows. Perfect for building databases, tracking metrics, saving form submissions, or creating data collection pipelines.",
          "elementId": "EXTENSION:::SHARED:::default:::google-sheets:::addRow",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Log the correction Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::google-sheets:::addRow",
          "legacyElementId": "JS###v1###GoogleSheets###addRow",
          "methodName": "addRow",
          "position": {
            "x": 400,
            "y": 400
          }
        },
        "flowElementId": "7FCAB4A2-B83B-4260-856E-8678AEE8A1F4",
        "groupId": "0EC7C910-A1FE-47E6-A20E-B9CFC8F7A35F",
        "id": "B403CE9D-91FE-49BD-AA25-46510BBBE5C4",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "documentId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sheetId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "NUMBER",
                    "label": null,
                    "type": "INPUT",
                    "value": 0
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "row",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "label": null,
                    "subPathSegments": [
                      {
                        "key": "logRow",
                        "optional": false
                      }
                    ],
                    "type": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "value": "0EC7C910-A1FE-47E6-A20E-B9CFC8F7A35F"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Log the correction', Error: Document is required",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "addRow",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Correction log",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "google-sheets",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Log the correction",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 614,
            "y": 564
          }
        },
        "flowElementId": "E77DA020-487B-4390-9244-E099BDADA096",
        "groupId": null,
        "id": "EA1BE401-85D3-41F6-885D-78FB7FC98A7C",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "166bbe85-a32b-4555-860c-387f8a538a7d",
                "nestedOperation": null,
                "operation": "equal",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Dispatch details",
                      "subPathSegments": [
                        {
                          "key": "wholeOrder",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "71F52924-D0D8-40E5-8787-DDE1DA2B11D3"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "STRING",
                "values": [
                  {
                    "expression": [
                      {
                        "id": "TEXT",
                        "label": null,
                        "type": "INPUT",
                        "value": "yes"
                      }
                    ],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                ]
              }
            ],
            "grouping": [
              "166bbe85-a32b-4555-860c-387f8a538a7d"
            ]
          },
          "elseComponent": {
            "componentId": "36B13579-CD6D-4ADD-B488-F16D5E597282",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Whole order",
          "storeResult": false,
          "thenComponent": {
            "componentId": "2F46C0F2-E4D0-4AB5-94E1-7484F6421639",
            "componentType": "ELEMENT"
          }
        },
        "name": "Whole order shipped?",
        "nextElementIds": [
          "2F46C0F2-E4D0-4AB5-94E1-7484F6421639",
          "36B13579-CD6D-4ADD-B488-F16D5E597282"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 118,
            "y": 442
          }
        },
        "flowElementId": "097B707D-E346-488A-B786-726B9AAF7501",
        "groupId": null,
        "id": "B7091A57-9DAF-4D1C-A309-BAEBD59F9486",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "376a74a9-1d36-4add-b50f-0b14c0c232b2",
                "nestedOperation": null,
                "operation": "equal",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Dispatch details",
                      "subPathSegments": [
                        {
                          "key": "hasCorrections",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "71F52924-D0D8-40E5-8787-DDE1DA2B11D3"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "STRING",
                "values": [
                  {
                    "expression": [
                      {
                        "id": "TEXT",
                        "label": null,
                        "type": "INPUT",
                        "value": "yes"
                      }
                    ],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                ]
              }
            ],
            "grouping": [
              "376a74a9-1d36-4add-b50f-0b14c0c232b2"
            ]
          },
          "elseComponent": null,
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Has corrections",
          "storeResult": false,
          "thenComponent": {
            "componentId": "0EC7C910-A1FE-47E6-A20E-B9CFC8F7A35F",
            "componentType": "GROUP"
          }
        },
        "name": "Any stock corrections?",
        "nextElementIds": [],
        "nextGroupIds": [
          "0EC7C910-A1FE-47E6-A20E-B9CFC8F7A35F"
        ],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Read the dispatch Result"
          },
          "position": {
            "x": 400,
            "y": 220
          }
        },
        "flowElementId": "0B24F411-271C-469E-9304-538D926CD2C2",
        "groupId": null,
        "id": "71F52924-D0D8-40E5-8787-DDE1DA2B11D3",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "dispatch",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Dispatch",
                    "subPathSegments": null,
                    "type": "TRIGGER_DATA",
                    "value": "14B6EBFB-A453-4980-AD5D-54D967125E26"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const d = dispatch || {};\nif (!d.salesOrderId) throw new Error('The dispatch has no salesOrderId.');\nconst pad = (n) => String(n).padStart(2, '0');\nconst holdedDate = (v) => {\n  if (!v) return '';\n  if (/^\\d{2}\\/\\d{2}\\/\\d{4}$/.test(v)) return v;\n  const t = new Date(v);\n  return isNaN(t) ? '' : `${pad(t.getUTCDate())}/${pad(t.getUTCMonth() + 1)}/${t.getUTCFullYear()}`;\n};\nconst lines = (Array.isArray(d.lines) ? d.lines : []).filter((l) => l && Number(l.units) > 0);\nconst today = new Date().toISOString().slice(0, 10);\nconst corrections = (Array.isArray(d.stockCorrections) ? d.stockCorrections : []).map((c) => ({\n  productId: String(c.productId),\n  warehouseId: c.warehouseId || '',\n  stock: Number(c.stock),\n  logRow: {\n    Date: today,\n    'Sales order': d.salesOrderNumber || d.salesOrderId,\n    Product: c.productName || c.productId,\n    Warehouse: c.warehouseName || c.warehouseId || 'Default',\n    'New stock': Number(c.stock),\n    Reason: c.reason || 'No reason given',\n  },\n}));\nreturn {\n  orderId: String(d.salesOrderId),\n  trackingNumbers: [].concat(d.trackingNumbers || d.trackingNumber || []).map(String),\n  carrierKey: d.carrierKey || '',\n  carrierName: d.carrierName || '',\n  pickUpDate: holdedDate(d.pickUpDate || new Date().toISOString()),\n  wholeOrder: lines.length ? 'no' : 'yes',\n  lines,\n  corrections,\n  hasCorrections: corrections.length ? 'yes' : 'no',\n};"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Dispatch details",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Read the dispatch",
        "nextElementIds": [
          "B7091A57-9DAF-4D1C-A309-BAEBD59F9486",
          "D8FE6A2F-32FF-43AB-8F79-CD55F93F0FD3"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 924,
            "y": 998
          }
        },
        "flowElementId": "7B45CC12-1C8E-40EE-AB1B-FD10C1496A02",
        "groupId": null,
        "id": "A303E19F-BCAB-442F-ACC2-2851C0C6EB5A",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "b3ee988c-99d4-4804-987e-5cb94bd8a8d8",
                "nestedOperation": null,
                "operation": "equal",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Shipment count",
                      "subPathSegments": [
                        {
                          "key": "allShipped",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "A05BA37C-358C-4FB2-B266-1DDAFF162491"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "STRING",
                "values": [
                  {
                    "expression": [
                      {
                        "id": "TEXT",
                        "label": null,
                        "type": "INPUT",
                        "value": "yes"
                      }
                    ],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                ]
              }
            ],
            "grouping": [
              "b3ee988c-99d4-4804-987e-5cb94bd8a8d8"
            ]
          },
          "elseComponent": null,
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Everything shipped",
          "storeResult": false,
          "thenComponent": {
            "componentId": "D3424BBB-7264-4A11-A048-26E3BE1C4F8A",
            "componentType": "ELEMENT"
          }
        },
        "name": "Everything shipped?",
        "nextElementIds": [
          "D3424BBB-7264-4A11-A048-26E3BE1C4F8A"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "notes": "Moves a Holded sales order or waybill to another stage of its pipeline.",
          "elementId": "EXTENSION:::SHARED:::default:::holded:::setDocumentPipeline",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Move the order to Shipped Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::holded:::setDocumentPipeline",
          "legacyElementId": "JS###v1###HoldedService###setDocumentPipeline",
          "methodName": "setDocumentPipeline",
          "position": {
            "x": 1266,
            "y": 994
          }
        },
        "flowElementId": "397CA3E5-71A1-4690-9F2C-DFA1D45503F0",
        "groupId": null,
        "id": "D3424BBB-7264-4A11-A048-26E3BE1C4F8A",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "documentId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Dispatch details",
                    "subPathSegments": [
                      {
                        "key": "orderId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "71F52924-D0D8-40E5-8787-DDE1DA2B11D3"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "pipeline",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Shipped stage",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Shipped stage"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "documentType",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "salesorder"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "setDocumentPipeline",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Stage change",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "holded",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Move the order to Shipped",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Sets the stock level of a Holded product. This is a correction rather than a movement, and it creates no document.",
          "elementId": "EXTENSION:::SHARED:::default:::holded:::updateProductStock",
          "isFirstElement": true,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Set the corrected stock Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::holded:::updateProductStock",
          "legacyElementId": "JS###v1###HoldedService###updateProductStock",
          "methodName": "updateProductStock",
          "position": {
            "x": 110,
            "y": 400
          }
        },
        "flowElementId": "04513A59-2DD9-4762-A26A-5F939C8A8CE7",
        "groupId": "0EC7C910-A1FE-47E6-A20E-B9CFC8F7A35F",
        "id": "36EBF2A5-08DE-4211-A57E-5AC6E4A3E323",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "productId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "label": null,
                    "subPathSegments": [
                      {
                        "key": "productId",
                        "optional": false
                      }
                    ],
                    "type": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "value": "0EC7C910-A1FE-47E6-A20E-B9CFC8F7A35F"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "stock",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "label": null,
                    "subPathSegments": [
                      {
                        "key": "stock",
                        "optional": false
                      }
                    ],
                    "type": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "value": "0EC7C910-A1FE-47E6-A20E-B9CFC8F7A35F"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "warehouseId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "label": null,
                    "subPathSegments": [
                      {
                        "key": "warehouseId",
                        "optional": false
                      }
                    ],
                    "type": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "value": "0EC7C910-A1FE-47E6-A20E-B9CFC8F7A35F"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "updateProductStock",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Stock correction",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "holded",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Set the corrected stock",
        "nextElementIds": [
          "B403CE9D-91FE-49BD-AA25-46510BBBE5C4"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Marks every line of a Holded sales order as shipped.",
          "elementId": "EXTENSION:::SHARED:::default:::holded:::shipAllItems",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Ship every line Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::holded:::shipAllItems",
          "legacyElementId": "JS###v1###HoldedService###shipAllItems",
          "methodName": "shipAllItems",
          "position": {
            "x": 926,
            "y": 748
          }
        },
        "flowElementId": "29C1271E-D2B5-475B-8651-BBAA483ECE5D",
        "groupId": null,
        "id": "2F46C0F2-E4D0-4AB5-94E1-7484F6421639",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "documentId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Dispatch details",
                    "subPathSegments": [
                      {
                        "key": "orderId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "71F52924-D0D8-40E5-8787-DDE1DA2B11D3"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "shipAllItems",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Shipped all",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "holded",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Ship every line",
        "nextElementIds": [
          "FE77BB20-D600-4B43-9872-DB9140176A35"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Marks named quantities of a Holded sales order as shipped, line by line.",
          "elementId": "EXTENSION:::SHARED:::default:::holded:::shipItemsByLine",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Ship the named quantities Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::holded:::shipItemsByLine",
          "legacyElementId": "JS###v1###HoldedService###shipItemsByLine",
          "methodName": "shipItemsByLine",
          "position": {
            "x": 260,
            "y": 744
          }
        },
        "flowElementId": "4DB8B91A-7738-4E7A-8616-2F41D022B67E",
        "groupId": null,
        "id": "36B13579-CD6D-4ADD-B488-F16D5E597282",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "documentId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Dispatch details",
                    "subPathSegments": [
                      {
                        "key": "orderId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "71F52924-D0D8-40E5-8787-DDE1DA2B11D3"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "lines",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Dispatch details",
                    "subPathSegments": [
                      {
                        "key": "lines",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "71F52924-D0D8-40E5-8787-DDE1DA2B11D3"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "shipItemsByLine",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Shipped lines",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "holded",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Ship the named quantities",
        "nextElementIds": [
          "FE77BB20-D600-4B43-9872-DB9140176A35"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Count what has shipped Result"
          },
          "position": {
            "x": 580,
            "y": 1008
          }
        },
        "flowElementId": "47FFC9FC-8A9A-4965-B6DB-C155277A3E5E",
        "groupId": null,
        "id": "A05BA37C-358C-4FB2-B266-1DDAFF162491",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "shipped",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Shipped items",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "FE77BB20-D600-4B43-9872-DB9140176A35"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const items = Array.isArray(shipped?.items) ? shipped.items : (Array.isArray(shipped) ? shipped : []);\nconst allShipped = items.length > 0 && items.every((i) => Number(i.shipped) >= Number(i.ordered));\nreturn {\n  allShipped: allShipped ? 'yes' : 'no',\n  summary: items.map((i) => `${i.name}: ${i.shipped} of ${i.ordered}`).join(', '),\n};"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Shipment count",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Count what has shipped",
        "nextElementIds": [
          "A303E19F-BCAB-442F-ACC2-2851C0C6EB5A"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      }
    ],
    "firstElementId": "14B6EBFB-A453-4980-AD5D-54D967125E26",
    "groups": [
      {
        "clientMetadata": {
          "elementId": "list-iterator",
          "isFirstElement": false,
          "blockDefinitionId": "list-iterator",
          "viewport": {
            "x": 0,
            "y": 0,
            "zoom": 0.8
          },
          "position": {
            "x": 110,
            "y": 582
          }
        },
        "flowElementId": "14CAF8E8-7E6D-43F2-86A9-85BDA3D508AE",
        "groupId": null,
        "id": "0EC7C910-A1FE-47E6-A20E-B9CFC8F7A35F",
        "loopType": "LIST_ITERATOR",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": "Block: 'For each stock correction', Error: Children have error",
            "valid": false
          },
          "enabled": true,
          "firstElementId": "36EBF2A5-08DE-4211-A57E-5AC6E4A3E323",
          "list": {
            "expression": [
              {
                "id": "ELEMENT_RESULT",
                "label": "Dispatch details",
                "subPathSegments": [
                  {
                    "key": "corrections",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "71F52924-D0D8-40E5-8787-DDE1DA2B11D3"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "onFailElemId": null,
          "resultAlias": "loop",
          "storeResult": true
        },
        "name": "For each stock correction",
        "nextElementIds": [],
        "nextGroupIds": [],
        "type": "LOOP"
      }
    ],
    "id": "2627A89E-C86D-440E-BB0E-F1BA35118C1D",
    "metaInfo": {
      "clientValidationState": {
        "errorMessage": "Please fix problems before start. Blocks with issues have red badge in the top-right corner of a block, hover it to see what needs to be done.",
        "valid": false
      },
      "errorMessage": "Please fix problems before start. Blocks with issues have red badge in the top-right corner of a block, hover it to see what needs to be done.",
      "executionStaticData": [
        {
          "description": "The stage of your Holded sales order pipeline that a fully shipped order moves to.",
          "error": null,
          "name": "Shipped stage",
          "type": "STRING",
          "value": ""
        }
      ],
      "initialData": null,
      "initialDataDefaultValues": {},
      "ownerFlowVersionId": null,
      "schedule": null,
      "sharedMemory": {
        "anchor": {
          "missingAnchorPolicy": null,
          "path": null,
          "type": "FLOW_MEMORY"
        },
        "expirationInSec": null
      },
      "wasLive": false
    }
  },
  "slaCalendars": [],
  "slaGoals": [],
  "subFlows": [],
  "exportDate": "2026-11-17T05:54:49.903Z"
}
