{
  "elementsLearnedData": [],
  "elementsTestData": [],
  "flow": {
    "id": "71082325-68A7-48DC-98B6-380B81F7A13D",
    "name": "SharePoint: load paperwork archived by customer"
  },
  "flowVersion": {
    "clientMetadata": {
      "viewport": {
        "x": -18.82352941176471,
        "y": 18.609625668449198,
        "zoom": 0.53
      },
      "autoSave": false,
      "descriptions": {
        "flow": "When a load is marked ready to bill in McLeod LoadMaster, every document McLeod Imaging holds for it (rate con, BOL, POD and the rest) is copied as a PDF to SharePoint, into a folder per load inside a folder per customer and delivery month, creating the folders as needed.",
        "initialData": "",
        "initialDataFields": {}
      }
    },
    "description": "When a load is marked ready to bill in McLeod LoadMaster, every document McLeod Imaging holds for it (rate con, BOL, POD and the rest) is copied as a PDF to SharePoint, into a folder per load inside a folder per customer and delivery month, creating the folders as needed.",
    "elements": [
      {
        "clientMetadata": {
          "elementId": "error-handler",
          "isFirstElement": false,
          "blockDefinitionId": "error-handler",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "No month folder yet Result"
          },
          "position": {
            "x": 136,
            "y": 1259
          }
        },
        "flowElementId": "312608D9-CD25-487A-83BA-191B8B698840",
        "groupId": null,
        "id": "51933AE2-8A70-4ED4-8F0B-87B906B528FE",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "No month folder",
          "saveToVariable": null,
          "storeResult": true
        },
        "name": "No month folder yet",
        "nextElementIds": [
          "3FD1CB3F-CB08-44A8-ACA3-C32142B43B2A"
        ],
        "nextGroupIds": [],
        "type": "ERROR_HANDLER"
      },
      {
        "clientMetadata": {
          "notes": "Creates a new folder inside a drive folder. Leave parent folder blank to create at the drive root.",
          "elementId": "EXTENSION:::SHARED:::default:::sharepoint:::createFolder",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Create the month folder Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::sharepoint:::createFolder",
          "legacyElementId": "JS###v1###SharePointService###createFolder",
          "methodName": "createFolder",
          "position": {
            "x": 124,
            "y": 600
          }
        },
        "flowElementId": "F7B89D62-C217-43BB-9BCC-91052772CC3A",
        "groupId": null,
        "id": "90C1C247-006A-4F00-A0C0-3D5FBC9FD3A3",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "siteId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Plan",
                    "subPathSegments": [
                      {
                        "key": "siteId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "9457CF88-DDFA-4BC8-B514-9D59A6EF448E"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "driveId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Plan",
                    "subPathSegments": [
                      {
                        "key": "driveId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "9457CF88-DDFA-4BC8-B514-9D59A6EF448E"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "parentFolderId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Customer folder",
                    "subPathSegments": [
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "3FD1CB3F-CB08-44A8-ACA3-C32142B43B2A"
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "New customer folder",
                    "subPathSegments": [
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "BB8FDCCF-AA40-43FF-969A-7DB9C96DC691"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "folderName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Plan",
                    "subPathSegments": [
                      {
                        "key": "monthFolder",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "9457CF88-DDFA-4BC8-B514-9D59A6EF448E"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "conflictBehavior",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "fail"
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Create the month folder', Error: OAuth Connection is required",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "createFolder",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "New month folder",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "sharepoint",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Create the month folder",
        "nextElementIds": [
          "9252941D-24DE-4CEC-9801-425D17F2122D"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Creates a new folder inside a drive folder. Leave parent folder blank to create at the drive root.",
          "elementId": "EXTENSION:::SHARED:::default:::sharepoint:::createFolder",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Create the load folder Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::sharepoint:::createFolder",
          "legacyElementId": "JS###v1###SharePointService###createFolder",
          "methodName": "createFolder",
          "position": {
            "x": 131,
            "y": 730
          }
        },
        "flowElementId": "8F86E1DE-AC5F-4D94-B558-B0598014359F",
        "groupId": null,
        "id": "9252941D-24DE-4CEC-9801-425D17F2122D",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "siteId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Plan",
                    "subPathSegments": [
                      {
                        "key": "siteId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "9457CF88-DDFA-4BC8-B514-9D59A6EF448E"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "driveId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Plan",
                    "subPathSegments": [
                      {
                        "key": "driveId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "9457CF88-DDFA-4BC8-B514-9D59A6EF448E"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "parentFolderId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Month folder",
                    "subPathSegments": [
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "25B24B54-A556-488C-A6B8-B2828D6B0A61"
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "New month folder",
                    "subPathSegments": [
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "90C1C247-006A-4F00-A0C0-3D5FBC9FD3A3"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "folderName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Plan",
                    "subPathSegments": [
                      {
                        "key": "loadFolder",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "9457CF88-DDFA-4BC8-B514-9D59A6EF448E"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "conflictBehavior",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "fail"
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Create the load folder', Error: OAuth Connection is required",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "createFolder",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "New load folder",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "sharepoint",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Create the load folder",
        "nextElementIds": [],
        "nextGroupIds": [
          "C7549979-AE91-4FCA-A304-931F5D26FF9E"
        ],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Retrieves all document libraries (drives) for a SharePoint site.",
          "elementId": "EXTENSION:::SHARED:::default:::sharepoint:::getDrives",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "List the document libraries Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::sharepoint:::getDrives",
          "legacyElementId": "JS###v1###SharePointService###getDrives",
          "methodName": "getDrives",
          "position": {
            "x": 785,
            "y": 40
          }
        },
        "flowElementId": "D43CCA6D-8922-49FA-BBF8-92FE5BCEB226",
        "groupId": null,
        "id": "9AC667F2-FBE5-4D55-926F-9F19D4A6EE17",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "siteId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Site",
                    "subPathSegments": [
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "A348D76D-AE48-4956-88D5-3F119B47CE27"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'List the document libraries', Error: OAuth Connection is required",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "getDrives",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Libraries",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "sharepoint",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "List the document libraries",
        "nextElementIds": [
          "9457CF88-DDFA-4BC8-B514-9D59A6EF448E"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Lists the documents McLeod Imaging holds for a load (rate confirmation, BOL, POD and the rest): those attached to the order and, unless turned off, those attached to its movements. Each has the ID that Download Document takes.",
          "elementId": "EXTENSION:::SHARED:::default:::mcleod-loadmaster:::listLoadDocuments",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "List the load's documents Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::mcleod-loadmaster:::listLoadDocuments",
          "legacyElementId": null,
          "methodName": "listLoadDocuments",
          "position": {
            "x": 1128,
            "y": 860
          }
        },
        "flowElementId": "5DA96256-C340-440B-BCC9-A3192F006E47",
        "groupId": null,
        "id": "7BD42075-0733-4E0A-82B5-32BD453B0184",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "orderId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Ready load",
                    "subPathSegments": [
                      {
                        "key": "orderId",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "7732C03C-EB35-46A9-ADF3-AD339D06F2CD"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "includeMovementDocuments",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_TRUE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": true
                  }
                ],
                "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": "listLoadDocuments",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "McLeod documents",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "mcleod-loadmaster",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "List the load's documents",
        "nextElementIds": [
          "4BA914BA-08D6-4123-A5BF-B6F98C618774"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Retrieves a drive item by its path within the drive root.",
          "elementId": "EXTENSION:::SHARED:::default:::sharepoint:::getDriveItemByPath",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Find the archive folder Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::sharepoint:::getDriveItemByPath",
          "legacyElementId": "JS###v1###SharePointService###getDriveItemByPath",
          "methodName": "getDriveItemByPath",
          "position": {
            "x": 129,
            "y": 340
          }
        },
        "flowElementId": "ED530C4F-BE9E-47C6-875A-C11412855241",
        "groupId": null,
        "id": "4D3B14C0-C5A4-472E-88A2-64C1986599B3",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "siteId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Plan",
                    "subPathSegments": [
                      {
                        "key": "siteId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "9457CF88-DDFA-4BC8-B514-9D59A6EF448E"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "driveId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Plan",
                    "subPathSegments": [
                      {
                        "key": "driveId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "9457CF88-DDFA-4BC8-B514-9D59A6EF448E"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "itemPath",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Plan",
                    "subPathSegments": [
                      {
                        "key": "archivePath",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "9457CF88-DDFA-4BC8-B514-9D59A6EF448E"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Find the archive folder', Error: OAuth Connection is required",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "getDriveItemByPath",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Archive folder",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "sharepoint",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Find the archive folder",
        "nextElementIds": [
          "BB8FDCCF-AA40-43FF-969A-7DB9C96DC691"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Creates a new folder inside a drive folder. Leave parent folder blank to create at the drive root.",
          "elementId": "EXTENSION:::SHARED:::default:::sharepoint:::createFolder",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Create the customer folder Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::sharepoint:::createFolder",
          "legacyElementId": "JS###v1###SharePointService###createFolder",
          "methodName": "createFolder",
          "position": {
            "x": 114,
            "y": 210
          }
        },
        "flowElementId": "1AA73174-92AC-4FC3-AE82-7859E9E6B47B",
        "groupId": null,
        "id": "BB8FDCCF-AA40-43FF-969A-7DB9C96DC691",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "siteId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Plan",
                    "subPathSegments": [
                      {
                        "key": "siteId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "9457CF88-DDFA-4BC8-B514-9D59A6EF448E"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "driveId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Plan",
                    "subPathSegments": [
                      {
                        "key": "driveId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "9457CF88-DDFA-4BC8-B514-9D59A6EF448E"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "parentFolderId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Archive folder",
                    "subPathSegments": [
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "4D3B14C0-C5A4-472E-88A2-64C1986599B3"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "folderName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Plan",
                    "subPathSegments": [
                      {
                        "key": "customerFolder",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "9457CF88-DDFA-4BC8-B514-9D59A6EF448E"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "conflictBehavior",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "fail"
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Create the customer folder', Error: OAuth Connection is required",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "createFolder",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "New customer folder",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "sharepoint",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Create the customer folder",
        "nextElementIds": [
          "90C1C247-006A-4F00-A0C0-3D5FBC9FD3A3"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "error-handler",
          "isFirstElement": false,
          "blockDefinitionId": "error-handler",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "No load folder yet Result"
          },
          "position": {
            "x": 136,
            "y": 999
          }
        },
        "flowElementId": "F41A96F2-8B6E-40E9-8F8A-D7212C3523E4",
        "groupId": null,
        "id": "9F477837-A8BF-4715-82D5-4DAAE381A776",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "No load folder",
          "saveToVariable": null,
          "storeResult": true
        },
        "name": "No load folder yet",
        "nextElementIds": [
          "25B24B54-A556-488C-A6B8-B2828D6B0A61"
        ],
        "nextGroupIds": [],
        "type": "ERROR_HANDLER"
      },
      {
        "clientMetadata": {
          "elementId": "error-handler",
          "isFirstElement": false,
          "blockDefinitionId": "error-handler",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "No customer folder yet Result"
          },
          "position": {
            "x": 127,
            "y": 479
          }
        },
        "flowElementId": "C5E064D5-F7CB-4AFB-81D3-8D62FD7108ED",
        "groupId": null,
        "id": "434C1A71-3F6C-4C9B-8BC1-F4F3EA0A4BCE",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "No customer folder",
          "saveToVariable": null,
          "storeResult": true
        },
        "name": "No customer folder yet",
        "nextElementIds": [
          "4D3B14C0-C5A4-472E-88A2-64C1986599B3"
        ],
        "nextGroupIds": [],
        "type": "ERROR_HANDLER"
      },
      {
        "clientMetadata": {
          "notes": "Retrieves a drive item by its path within the drive root.",
          "elementId": "EXTENSION:::SHARED:::default:::sharepoint:::getDriveItemByPath",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Find the load folder Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::sharepoint:::getDriveItemByPath",
          "legacyElementId": "JS###v1###SharePointService###getDriveItemByPath",
          "methodName": "getDriveItemByPath",
          "position": {
            "x": 474,
            "y": 860
          }
        },
        "flowElementId": "203C1AE4-C384-4D5B-9E0F-CC403F3D3A50",
        "groupId": null,
        "id": "60005294-DF33-48CC-9D3A-5800246FB3E2",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "siteId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Plan",
                    "subPathSegments": [
                      {
                        "key": "siteId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "9457CF88-DDFA-4BC8-B514-9D59A6EF448E"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "driveId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Plan",
                    "subPathSegments": [
                      {
                        "key": "driveId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "9457CF88-DDFA-4BC8-B514-9D59A6EF448E"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "itemPath",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Plan",
                    "subPathSegments": [
                      {
                        "key": "loadPath",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "9457CF88-DDFA-4BC8-B514-9D59A6EF448E"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Find the load folder', Error: OAuth Connection is required",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "getDriveItemByPath",
          "onFailElemId": "9F477837-A8BF-4715-82D5-4DAAE381A776",
          "packageId": "default",
          "resultAlias": "Load folder",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "sharepoint",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Find the load folder",
        "nextElementIds": [],
        "nextGroupIds": [
          "C7549979-AE91-4FCA-A304-931F5D26FF9E"
        ],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Retrieves a drive item by its path within the drive root.",
          "elementId": "EXTENSION:::SHARED:::default:::sharepoint:::getDriveItemByPath",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Find the month folder Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::sharepoint:::getDriveItemByPath",
          "legacyElementId": "JS###v1###SharePointService###getDriveItemByPath",
          "methodName": "getDriveItemByPath",
          "position": {
            "x": 132,
            "y": 1120
          }
        },
        "flowElementId": "C803473B-B66E-4DA0-B51B-593EE19BB587",
        "groupId": null,
        "id": "25B24B54-A556-488C-A6B8-B2828D6B0A61",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "siteId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Plan",
                    "subPathSegments": [
                      {
                        "key": "siteId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "9457CF88-DDFA-4BC8-B514-9D59A6EF448E"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "driveId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Plan",
                    "subPathSegments": [
                      {
                        "key": "driveId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "9457CF88-DDFA-4BC8-B514-9D59A6EF448E"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "itemPath",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Plan",
                    "subPathSegments": [
                      {
                        "key": "monthPath",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "9457CF88-DDFA-4BC8-B514-9D59A6EF448E"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Find the month folder', Error: OAuth Connection is required",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "getDriveItemByPath",
          "onFailElemId": "51933AE2-8A70-4ED4-8F0B-87B906B528FE",
          "packageId": "default",
          "resultAlias": "Month folder",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "sharepoint",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Find the month folder",
        "nextElementIds": [
          "9252941D-24DE-4CEC-9801-425D17F2122D"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 807,
            "y": 869
          }
        },
        "flowElementId": "DC9AEF77-FDB1-4638-805C-256F84EC29EF",
        "groupId": null,
        "id": "4BA914BA-08D6-4123-A5BF-B6F98C618774",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "634fb62f-9c99-426a-a6c6-b10d58ed72ba",
                "nestedOperation": null,
                "operation": ">",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "McLeod documents",
                      "subPathSegments": [
                        {
                          "key": "count",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "7BD42075-0733-4E0A-82B5-32BD453B0184"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "INT",
                "values": [
                  {
                    "expression": [
                      {
                        "id": "NUMBER",
                        "label": null,
                        "type": "INPUT",
                        "value": 0
                      }
                    ],
                    "mode": "EXPRESSION",
                    "parseJsonString": false,
                    "resultType": null
                  }
                ]
              }
            ],
            "grouping": [
              "634fb62f-9c99-426a-a6c6-b10d58ed72ba"
            ]
          },
          "elseComponent": null,
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "Any documents",
          "storeResult": false,
          "thenComponent": {
            "componentId": "60005294-DF33-48CC-9D3A-5800246FB3E2",
            "componentType": "ELEMENT"
          }
        },
        "name": "Any documents?",
        "nextElementIds": [
          "60005294-DF33-48CC-9D3A-5800246FB3E2"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "notes": "Uploads a file to a SharePoint document library by URL or text content. For files larger than 4 MB, prefer downloading first into FlowRunner Files. Files up to 4 MB are uploaded directly via Graph small-file upload.",
          "elementId": "EXTENSION:::SHARED:::default:::sharepoint:::uploadFile",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Save it to the load folder Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::sharepoint:::uploadFile",
          "legacyElementId": "JS###v1###SharePointService###uploadFile",
          "methodName": "uploadFile",
          "position": {
            "x": 446,
            "y": 70
          }
        },
        "flowElementId": "13C08E42-F7A0-4CD6-A9BB-A1343EC0CB89",
        "groupId": "C7549979-AE91-4FCA-A304-931F5D26FF9E",
        "id": "40E5F701-7789-4952-BAA5-AD95B27A2AC8",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "siteId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Plan",
                    "subPathSegments": [
                      {
                        "key": "siteId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "9457CF88-DDFA-4BC8-B514-9D59A6EF448E"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "driveId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Plan",
                    "subPathSegments": [
                      {
                        "key": "driveId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "9457CF88-DDFA-4BC8-B514-9D59A6EF448E"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "parentFolderId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Load folder",
                    "subPathSegments": [
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "60005294-DF33-48CC-9D3A-5800246FB3E2"
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "New load folder",
                    "subPathSegments": [
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "9252941D-24DE-4CEC-9801-425D17F2122D"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "fileName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Archive copy",
                    "subPathSegments": [
                      {
                        "key": "filename",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "B6384E0E-D7FF-4919-99E4-AC0A72F3421D"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sourceUrl",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Archive copy",
                    "subPathSegments": [
                      {
                        "key": "url",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "B6384E0E-D7FF-4919-99E4-AC0A72F3421D"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "content",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "contentType",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Archive copy",
                    "subPathSegments": [
                      {
                        "key": "contentType",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "B6384E0E-D7FF-4919-99E4-AC0A72F3421D"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "conflictBehavior",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "replace"
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Save it to the load folder', Error: OAuth Connection is required",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "uploadFile",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Saved copy",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "sharepoint",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Save it to the load folder",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Retrieves a SharePoint site by hostname and server-relative path.",
          "elementId": "EXTENSION:::SHARED:::default:::sharepoint:::getSiteByPath",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Find the SharePoint site Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::sharepoint:::getSiteByPath",
          "legacyElementId": "JS###v1###SharePointService###getSiteByPath",
          "methodName": "getSiteByPath",
          "position": {
            "x": 462,
            "y": 40
          }
        },
        "flowElementId": "96BAD355-5426-4176-A764-2BFBB64F0D41",
        "groupId": null,
        "id": "A348D76D-AE48-4956-88D5-3F119B47CE27",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "hostname",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "SharePoint host name",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "SharePoint host name"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sitePath",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "SharePoint site path",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "SharePoint site path"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Find the SharePoint site', Error: OAuth Connection is required",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "getSiteByPath",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Site",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "sharepoint",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Find the SharePoint site",
        "nextElementIds": [
          "9AC667F2-FBE5-4D55-926F-9F19D4A6EE17"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Plan the archive folders Result"
          },
          "position": {
            "x": 1136,
            "y": 49
          }
        },
        "flowElementId": "A070499F-D4C8-47D2-AE0B-73AA9E6D932D",
        "groupId": null,
        "id": "9457CF88-DDFA-4BC8-B514-9D59A6EF448E",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "drives",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Libraries",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "9AC667F2-FBE5-4D55-926F-9F19D4A6EE17"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "library",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Document library",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Document library"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "archive",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Archive folder",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Archive folder"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "site",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Site",
                    "subPathSegments": [
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "A348D76D-AE48-4956-88D5-3F119B47CE27"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "load",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Ready load",
                    "subPathSegments": null,
                    "type": "TRIGGER_DATA",
                    "value": "7732C03C-EB35-46A9-ADF3-AD339D06F2CD"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const list = drives && Array.isArray(drives.value) ? drives.value : (Array.isArray(drives) ? drives : []);\nconst want = String(library || '').trim().toLowerCase();\nconst drive = list.find((d) => String(d.name || '').trim().toLowerCase() === want);\nif (!drive) {\n  throw new Error(`No document library named \"${library}\" on this SharePoint site. Libraries found: ${list.map((d) => d.name).join(', ') || 'none'}`);\n}\nconst clean = (s) => String(s == null ? '' : s).replace(/[\"*:<>?\\/\\\\|#%{}~&]/g, ' ').replace(/\\s+/g, ' ').trim().replace(/[. ]+$/, '');\nconst l = load && typeof load === 'object' ? load : {};\nconst cust = l.customer || {};\nconst customerFolder = clean(cust.name ? `${cust.name} (${cust.id})` : (cust.id || 'No customer')) || 'No customer';\nconst stops = Array.isArray(l.stops) ? l.stops : [];\nconst last = stops[stops.length - 1] || {};\nconst when = String(last.actualArrival || last.actualDeparture || last.scheduledArriveEarly || l.detectedAt || '');\nconst monthFolder = /^\\d{4}-\\d{2}/.test(when) ? when.slice(0, 7) : new Date().toISOString().slice(0, 7);\nconst loadFolder = clean(l.orderId);\nif (!loadFolder) throw new Error('The load has no order number.');\nconst root = String(archive || '').replace(/^\\/+|\\/+$/g, '');\nif (!root) throw new Error('Set the flow setting Archive folder.');\nconst customerPath = `${root}/${customerFolder}`;\nconst monthPath = `${customerPath}/${monthFolder}`;\nconst loadPath = `${monthPath}/${loadFolder}`;\nreturn { siteId: String(site || ''), driveId: drive.id, archivePath: root, customerFolder, monthFolder, loadFolder, customerPath, monthPath, loadPath };\n"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Plan",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Plan the archive folders",
        "nextElementIds": [
          "7BD42075-0733-4E0A-82B5-32BD453B0184"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Retrieves a drive item by its path within the drive root.",
          "elementId": "EXTENSION:::SHARED:::default:::sharepoint:::getDriveItemByPath",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Find the customer folder Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::sharepoint:::getDriveItemByPath",
          "legacyElementId": "JS###v1###SharePointService###getDriveItemByPath",
          "methodName": "getDriveItemByPath",
          "position": {
            "x": 122,
            "y": 1380
          }
        },
        "flowElementId": "24611750-24EF-4B59-A548-C9C8BD91A6DC",
        "groupId": null,
        "id": "3FD1CB3F-CB08-44A8-ACA3-C32142B43B2A",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "siteId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Plan",
                    "subPathSegments": [
                      {
                        "key": "siteId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "9457CF88-DDFA-4BC8-B514-9D59A6EF448E"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "driveId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Plan",
                    "subPathSegments": [
                      {
                        "key": "driveId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "9457CF88-DDFA-4BC8-B514-9D59A6EF448E"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "itemPath",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Plan",
                    "subPathSegments": [
                      {
                        "key": "customerPath",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "9457CF88-DDFA-4BC8-B514-9D59A6EF448E"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Find the customer folder', Error: OAuth Connection is required",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "getDriveItemByPath",
          "onFailElemId": "434C1A71-3F6C-4C9B-8BC1-F4F3EA0A4BCE",
          "packageId": "default",
          "resultAlias": "Customer folder",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "sharepoint",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Find the customer folder",
        "nextElementIds": [
          "90C1C247-006A-4F00-A0C0-3D5FBC9FD3A3"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Fires when a load's (McLeod order's) ready to bill flag is set. McLeod cannot register webhooks, so this polls the orders changed since the last check (it needs table auditing on orders). It starts from the In Progress and Delivered loads (up to 2,000); loads created after that are watched from the start.",
          "elementId": "EXTENSION:::SHARED:::default:::mcleod-loadmaster:::onLoadReadyToBill",
          "isFirstElement": true,
          "blockDefinitionId": "EXTENSION:::SHARED:::default:::mcleod-loadmaster:::onLoadReadyToBill",
          "newElementId": "EXTENSION:::SHARED:::default:::mcleod-loadmaster:::onLoadReadyToBill",
          "legacyElementId": null,
          "methodName": "onLoadReadyToBill",
          "position": {
            "x": 110,
            "y": 40
          }
        },
        "flowElementId": "8AA38362-0431-40EB-BB1A-E806F28E481A",
        "groupId": null,
        "id": "7732C03C-EB35-46A9-ADF3-AD339D06F2CD",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": null,
          "connectionId": null,
          "dynamicData": [],
          "eventName": "onLoadReadyToBill",
          "frequency": {
            "repeat": {
              "every": 900
            },
            "schedule": "custom"
          },
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": null
          },
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Ready load",
          "serviceId": "mcleod-loadmaster",
          "slaConditions": [],
          "staticData": {},
          "storeResult": true,
          "subtype": "POLLING",
          "type": "CUSTOM"
        },
        "name": "Load ready to bill in McLeod",
        "nextElementIds": [
          "A348D76D-AE48-4956-88D5-3F119B47CE27"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "TRIGGER"
      },
      {
        "clientMetadata": {
          "notes": "Downloads one document from McLeod Imaging, converted to the chosen format (PDF by default, which keeps every page of a multi-page TIFF), and saves it to FlowRunner file storage. Returns the stored file's URL.",
          "elementId": "EXTENSION:::SHARED:::default:::mcleod-loadmaster:::downloadDocument",
          "isFirstElement": true,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Download it from McLeod Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::mcleod-loadmaster:::downloadDocument",
          "legacyElementId": null,
          "methodName": "downloadDocument",
          "position": {
            "x": 110,
            "y": 70
          }
        },
        "flowElementId": "73CF54C4-1A9B-41D3-9CF0-F7CAC79C502B",
        "groupId": "C7549979-AE91-4FCA-A304-931F5D26FF9E",
        "id": "B6384E0E-D7FF-4919-99E4-AC0A72F3421D",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "documentId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "label": null,
                    "subPathSegments": [
                      {
                        "key": "documentId",
                        "optional": false
                      }
                    ],
                    "type": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "value": "C7549979-AE91-4FCA-A304-931F5D26FF9E"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "format",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "application/pdf"
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "fileName",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Ready load",
                    "subPathSegments": [
                      {
                        "key": "orderId",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "7732C03C-EB35-46A9-ADF3-AD339D06F2CD"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " "
                  },
                  {
                    "id": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "label": null,
                    "subPathSegments": [
                      {
                        "key": "documentTypeId",
                        "optional": false
                      }
                    ],
                    "type": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "value": "C7549979-AE91-4FCA-A304-931F5D26FF9E"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " "
                  },
                  {
                    "id": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "label": null,
                    "subPathSegments": [
                      {
                        "key": "documentId",
                        "optional": false
                      }
                    ],
                    "type": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "value": "C7549979-AE91-4FCA-A304-931F5D26FF9E"
                  }
                ],
                "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": "downloadDocument",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Archive copy",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "mcleod-loadmaster",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Download it from McLeod",
        "nextElementIds": [
          "40E5F701-7789-4952-BAA5-AD95B27A2AC8"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      }
    ],
    "firstElementId": "7732C03C-EB35-46A9-ADF3-AD339D06F2CD",
    "groups": [
      {
        "clientMetadata": {
          "elementId": "list-iterator",
          "isFirstElement": false,
          "blockDefinitionId": "list-iterator",
          "viewport": {
            "x": -70,
            "y": -30,
            "zoom": 1
          },
          "position": {
            "x": 136,
            "y": 869
          }
        },
        "flowElementId": "03C7F609-3C45-43E9-842D-82FF2E3DDB3B",
        "groupId": null,
        "id": "C7549979-AE91-4FCA-A304-931F5D26FF9E",
        "loopType": "LIST_ITERATOR",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": "Block: 'Each document', Error: Children have error",
            "valid": false
          },
          "enabled": true,
          "firstElementId": "B6384E0E-D7FF-4919-99E4-AC0A72F3421D",
          "list": {
            "expression": [
              {
                "id": "ELEMENT_RESULT",
                "label": "McLeod documents",
                "subPathSegments": [
                  {
                    "key": "documents",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "7BD42075-0733-4E0A-82B5-32BD453B0184"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "onFailElemId": null,
          "resultAlias": "Each document",
          "storeResult": true
        },
        "name": "Each document",
        "nextElementIds": [],
        "nextGroupIds": [],
        "type": "LOOP"
      }
    ],
    "id": "08F24E90-F501-4112-B2BC-A7606452EF5F",
    "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": "Your SharePoint host name, the part of a site's address before /sites.",
          "error": null,
          "name": "SharePoint host name",
          "type": "STRING",
          "value": ""
        },
        {
          "description": "The path of the SharePoint site that holds the archive, such as /sites/Operations.",
          "error": null,
          "name": "SharePoint site path",
          "type": "STRING",
          "value": ""
        },
        {
          "description": "The name of the document library on that site, as SharePoint shows it.",
          "error": null,
          "name": "Document library",
          "type": "STRING",
          "value": ""
        },
        {
          "description": "The folder in that library that holds the archive, by its path from the top of the library. Create it once before turning the flow on.",
          "error": null,
          "name": "Archive folder",
          "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-29T02:51:22.424Z"
}
