{
  "elementsLearnedData": [],
  "elementsTestData": [],
  "flow": {
    "id": "60292E54-55B7-4BB5-82DC-AB34EB5EFB72",
    "name": "FMCSA: weekly recheck of carriers on active loads"
  },
  "flowVersion": {
    "clientMetadata": {
      "viewport": {
        "x": -70,
        "y": -180,
        "zoom": 1
      },
      "autoSave": false,
      "descriptions": {
        "flow": "Run weekly. Lists the open McLeod loads (in progress and available), collects each load's carrier, finds each carrier at FMCSA by its exact name, checks operating status, authority, liability insurance on file and out-of-service orders, compares the results with the last week's rows in a Google Sheet, saves this week's rows, and tells the carrier compliance lead in Slack about anything that changed.",
        "initialData": "",
        "initialDataFields": {}
      }
    },
    "description": "Each week, lists the carriers on open McLeod loads, checks each one at FMCSA, compares the results with last week's in a Google Sheet, and tells the carrier compliance lead in Slack about any change in authority, insurance or out-of-service status.",
    "elements": [
      {
        "clientMetadata": {
          "elementId": "data-bucket",
          "isFirstElement": false,
          "blockDefinitionId": "data-bucket",
          "fieldKeys": {
            "Results": "3bdaad92-fe5f-4a2b-b26e-5b5b3dd569c6"
          },
          "position": {
            "x": 436,
            "y": 399
          }
        },
        "flowElementId": "C9300360-9ED7-47A1-8FB2-B82F2834CB85",
        "groupId": null,
        "id": "0C79104C-4355-4F99-9C64-4E515A325858",
        "metaInfo": {
          "bucketName": "Default",
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "fields": [
            {
              "name": "Results",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "EMPTY_LIST",
                    "label": null,
                    "type": "KEYWORD",
                    "value": "arrays.create()"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "b2",
          "storeResult": true
        },
        "name": "Start this week's results",
        "nextElementIds": [],
        "nextGroupIds": [
          "D1A66DB4-E267-4BAB-A55E-120602A4298F"
        ],
        "type": "DATA_BUCKET"
      },
      {
        "clientMetadata": {
          "notes": "Retrieves data from Google Sheets for AI agents to analyze spreadsheet content, process existing data, or extract information for automated workflows. Perfect for reading user submissions, analyzing data trends, or importing data for further processing.",
          "elementId": "EXTENSION:::SHARED:::default:::google-sheets:::getRows",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Read last week's results Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::google-sheets:::getRows",
          "legacyElementId": "JS###v1###GoogleSheets###getRows",
          "methodName": "getRows",
          "position": {
            "x": 110,
            "y": 560
          }
        },
        "flowElementId": "A02061AB-F434-4D3E-84B7-BDF603439A57",
        "groupId": null,
        "id": "9D8CFB5D-BA2A-422A-965F-48A13256E1DC",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "documentId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Carrier check sheet",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Carrier check sheet"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sheetId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Carrier check tab ID",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Carrier check tab ID"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "offset",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "limit",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "withRowNumbers",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Read last week's results', Error: The placeholder \"Carrier check sheet\" has no value",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "getRows",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Last week",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "google-sheets",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Read last week's results",
        "nextElementIds": [
          "E2C543D7-3876-4E3F-8B6C-2D73EEEBA9C3"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Adds multiple data rows to Google Sheets in bulk for AI agents to efficiently store large datasets, batch process results, or import data from external sources. Essential for high-volume data operations and bulk data migration workflows.",
          "elementId": "EXTENSION:::SHARED:::default:::google-sheets:::addRows",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Save this week's results Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::google-sheets:::addRows",
          "legacyElementId": "JS###v1###GoogleSheets###addRows",
          "methodName": "addRows",
          "position": {
            "x": 766,
            "y": 560
          }
        },
        "flowElementId": "64A3D2D9-DD33-4F3A-9ADC-58F4DE5F0686",
        "groupId": null,
        "id": "DFDA9877-EC41-4CED-A7E4-8F6CA795FFE0",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "documentId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Carrier check sheet",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Carrier check sheet"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sheetId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "PLACEHOLDER_DATA",
                    "label": "Carrier check tab ID",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_STATIC_DATA",
                    "value": "Carrier check tab ID"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "rows",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Changes",
                    "subPathSegments": [
                      {
                        "key": "rows",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E2C543D7-3876-4E3F-8B6C-2D73EEEBA9C3"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Save this week's results', Error: The placeholder \"Carrier check sheet\" has no value",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "addRows",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Saved rows",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "google-sheets",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Save this week's results",
        "nextElementIds": [
          "FAC5EC32-D562-4494-AC3D-378D34EF9DF1"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 1131,
            "y": 569
          }
        },
        "flowElementId": "5939CC16-A12F-48B2-8131-2D68EEDFB954",
        "groupId": null,
        "id": "FAC5EC32-D562-4494-AC3D-378D34EF9DF1",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "4bf44470-537e-42c1-9b18-5a16446f0e41",
                "nestedOperation": null,
                "operation": "isTrue",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Changes",
                      "subPathSegments": [
                        {
                          "key": "hasChanges",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "E2C543D7-3876-4E3F-8B6C-2D73EEEBA9C3"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "BOOLEAN",
                "values": []
              }
            ],
            "grouping": [
              "4bf44470-537e-42c1-9b18-5a16446f0e41"
            ]
          },
          "elseComponent": null,
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "any",
          "storeResult": false,
          "thenComponent": {
            "componentId": "64A2BBC8-5127-43A9-9230-74A770D4391D",
            "componentType": "ELEMENT"
          }
        },
        "name": "Anything changed?",
        "nextElementIds": [
          "64A2BBC8-5127-43A9-9230-74A770D4391D"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "notes": "Returns the out-of-service orders FMCSA holds for the carrier, each with its date and reason. An empty list means none are on record.",
          "elementId": "EXTENSION:::SHARED:::default:::fmcsa:::getCarrierOutOfServiceOrders",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Check out-of-service orders Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::fmcsa:::getCarrierOutOfServiceOrders",
          "legacyElementId": null,
          "methodName": "getCarrierOutOfServiceOrders",
          "position": {
            "x": 1088,
            "y": 570
          }
        },
        "flowElementId": "34DBBFAC-7744-47AA-A993-2AB840D324B6",
        "groupId": "D1A66DB4-E267-4BAB-A55E-120602A4298F",
        "id": "C9761C93-9D58-4EA0-A5C6-5C455A1A9B20",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "dotNumber",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Match",
                    "subPathSegments": [
                      {
                        "key": "dotNumber",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "911BB22C-4189-4D60-B922-165A0200D7E7"
                  }
                ],
                "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": "getCarrierOutOfServiceOrders",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "OOS orders",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "fmcsa",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Check out-of-service orders",
        "nextElementIds": [
          "8F9B7398-EC1A-4C62-BF60-9B17D256D019"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Lists loads (McLeod orders) one page at a time, filtered by status, ready to bill flag, customer and delivery date (the scheduled arrival at the consignee stop, in your McLeod server's time). Each load has its stops and customer as McLeod's order search returns them, without charges or movements (use Get Load for those). Pass Next Offset back as Offset for the next page; it is null on the last page.",
          "elementId": "EXTENSION:::SHARED:::default:::mcleod-loadmaster:::listLoads",
          "isFirstElement": true,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "List loads in progress Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::mcleod-loadmaster:::listLoads",
          "legacyElementId": null,
          "methodName": "listLoads",
          "position": {
            "x": 120,
            "y": 220
          }
        },
        "flowElementId": "B34868EE-1658-4257-B6FD-13C918C6A203",
        "groupId": null,
        "id": "3D009110-A7F8-4748-BAA0-BFA7B4FB8203",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "status",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "P"
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "readyToBill",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "customerId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "deliveryDateFrom",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "deliveryDateTo",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "limit",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "NUMBER",
                    "label": null,
                    "type": "INPUT",
                    "value": 1000
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "offset",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "NUMBER",
                    "label": null,
                    "type": "INPUT",
                    "value": 0
                  }
                ],
                "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": "listLoads",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Loads in progress",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "mcleod-loadmaster",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "List loads in progress",
        "nextElementIds": [
          "B18114B0-5E8A-4297-81D5-F540C0DE4EDF"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 1070,
            "y": 409
          }
        },
        "flowElementId": "BBA798E6-4E7D-493C-A8FB-1400F84368BB",
        "groupId": "D1A66DB4-E267-4BAB-A55E-120602A4298F",
        "id": "53792344-DA2B-44B2-85BE-665B55C856D6",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "f38a095f-60f6-4ea3-b73c-2f7d09162761",
                "nestedOperation": null,
                "operation": "isTrue",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Match",
                      "subPathSegments": [
                        {
                          "key": "identified",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "911BB22C-4189-4D60-B922-165A0200D7E7"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "BOOLEAN",
                "values": []
              }
            ],
            "grouping": [
              "f38a095f-60f6-4ea3-b73c-2f7d09162761"
            ]
          },
          "elseComponent": {
            "componentId": "8F9B7398-EC1A-4C62-BF60-9B17D256D019",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "one",
          "storeResult": false,
          "thenComponent": {
            "componentId": "C9761C93-9D58-4EA0-A5C6-5C455A1A9B20",
            "componentType": "ELEMENT"
          }
        },
        "name": "One FMCSA carrier by that name?",
        "nextElementIds": [
          "C9761C93-9D58-4EA0-A5C6-5C455A1A9B20",
          "8F9B7398-EC1A-4C62-BF60-9B17D256D019"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "elementId": "data-bucket",
          "isFirstElement": false,
          "blockDefinitionId": "data-bucket",
          "fieldKeys": {
            "Results": "07a4052f-38de-4710-9f26-0bd3e4914d65"
          },
          "position": {
            "x": 418,
            "y": 579
          }
        },
        "flowElementId": "10D145DC-3B30-4698-A8DC-9043998812B3",
        "groupId": "D1A66DB4-E267-4BAB-A55E-120602A4298F",
        "id": "4BE5367B-D7BC-4D31-9D3D-02DE9C235624",
        "metaInfo": {
          "bucketName": "Default",
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "fields": [
            {
              "name": "Results",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Results so far",
                    "subPathSegments": [
                      {
                        "key": "list",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "8F9B7398-EC1A-4C62-BF60-9B17D256D019"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "keepr",
          "storeResult": true
        },
        "name": "Keep this week's results",
        "nextElementIds": [],
        "nextGroupIds": [],
        "type": "DATA_BUCKET"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Compare with last week Result"
          },
          "position": {
            "x": 437,
            "y": 569
          }
        },
        "flowElementId": "09214735-85DF-40DF-9D8B-185394E71559",
        "groupId": null,
        "id": "E2C543D7-3876-4E3F-8B6C-2D73EEEBA9C3",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "lastRows",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Last week",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "9D8CFB5D-BA2A-422A-965F-48A13256E1DC"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "results",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "EXECUTION_CONTEXT_DATA_BUCKET_VARIABLE",
                    "label": "Default - Results",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_PATH",
                    "value": "executionContext.dataBuckets.Default.Results",
                    "valueSegments": [
                      {
                        "key": "executionContext",
                        "optional": false
                      },
                      {
                        "key": "dataBuckets",
                        "optional": false
                      },
                      {
                        "key": "Default",
                        "optional": false
                      },
                      {
                        "key": "Results",
                        "optional": false
                      }
                    ]
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const prev = {};\n(Array.isArray(lastRows) ? lastRows : []).forEach(r => { if (r && r['Carrier ID'] !== undefined && r['Carrier ID'] !== '') prev[String(r['Carrier ID'])] = r; });\nconst now = Array.isArray(results) ? results : [];\nconst money = n => '$' + Number(n || 0).toLocaleString('en-US');\nconst today = new Date().toISOString().slice(0, 10);\nconst changes = [];\nnow.forEach(x => {\n  const p = prev[x.id];\n  const lines = [];\n  if (x.fmcsaMatch !== 'Matched') {\n    if (!p || p['FMCSA match'] !== x.fmcsaMatch) lines.push('Could not be matched at FMCSA by name. ' + (x.why || '') + ' Check it by MC number.');\n  } else if (!p || p['FMCSA match'] !== 'Matched') {\n    if (x.allowed !== 'Yes') lines.push('FMCSA does not show it as allowed to operate.');\n    if (x.authority !== 'Active') lines.push('FMCSA shows no active common or contract authority.');\n    if (x.insuranceRequiredFlag && Number(x.insurance) < Number(x.insuranceRequired)) lines.push('Liability insurance on file is ' + money(x.insurance) + ', below the ' + money(x.insuranceRequired) + ' required.');\n    if (x.outOfService !== 'None') lines.push('Out-of-service order on record: ' + x.outOfService + '.');\n  } else {\n    if (String(p['Allowed to operate']) !== x.allowed) lines.push('Allowed to operate changed from ' + p['Allowed to operate'] + ' to ' + x.allowed + '.');\n    if (String(p['Authority']) !== x.authority) lines.push('Authority changed from ' + p['Authority'] + ' to ' + x.authority + '.');\n    if (Number(p['Insurance on file'] || 0) !== Number(x.insurance)) lines.push('Liability insurance on file changed from ' + money(p['Insurance on file']) + ' to ' + money(x.insurance) + (x.insuranceRequiredFlag ? ' (' + money(x.insuranceRequired) + ' required)' : '') + '.');\n    if (Number(p['Cargo insurance on file'] || 0) !== Number(x.cargo)) lines.push('Cargo insurance on file changed from ' + money(p['Cargo insurance on file']) + ' to ' + money(x.cargo) + '.');\n    if (Number(p['Bond on file'] || 0) !== Number(x.bond)) lines.push('Bond or trust on file changed from ' + money(p['Bond on file']) + ' to ' + money(x.bond) + '.');\n    if (String(p['Out of service']) !== x.outOfService) lines.push('Out-of-service orders changed from ' + p['Out of service'] + ' to ' + x.outOfService + '.');\n  }\n  if (lines.length) changes.push({ x, lines });\n});\nconst rows = now.map(x => ({\n  'Checked': today,\n  'Carrier ID': x.id,\n  'Carrier': x.name,\n  'USDOT': x.usdot,\n  'FMCSA match': x.fmcsaMatch,\n  'Allowed to operate': x.allowed,\n  'Authority': x.authority,\n  'Insurance on file': x.insurance,\n  'Cargo insurance on file': x.cargo,\n  'Bond on file': x.bond,\n  'Out of service': x.outOfService,\n  'Active loads': (x.loads || []).join(', '),\n}));\nconst text = '*Weekly carrier check: ' + changes.length + (changes.length === 1 ? ' carrier' : ' carriers') + ' on active loads changed at FMCSA*\\n'\n  + changes.map(ch => '*' + ch.x.name + '*' + (ch.x.usdot ? ', USDOT ' + ch.x.usdot : '') + ', loads ' + (ch.x.loads || []).join(', ') + '\\n' + ch.lines.map(l => '- ' + l).join('\\n')).join('\\n\\n')\n  + '\\n\\n' + now.length + ' carriers checked. Every result is in the carrier check sheet.';\nreturn { hasChanges: changes.length > 0, changeCount: changes.length, rows, text };\n"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Changes",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Compare with last week",
        "nextElementIds": [
          "DFDA9877-EC41-4CED-A7E4-8F6CA795FFE0"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "data-bucket",
          "isFirstElement": false,
          "blockDefinitionId": "data-bucket",
          "fieldKeys": {
            "Carriers": "343d6c02-1737-45f6-b083-8330312d287a"
          },
          "position": {
            "x": 1131,
            "y": 229
          }
        },
        "flowElementId": "103DF95E-C2F2-4D66-B360-00E78CB6B891",
        "groupId": null,
        "id": "D608AC9A-14BD-4BEA-9F3A-91A1373D16F2",
        "metaInfo": {
          "bucketName": "Default",
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "fields": [
            {
              "name": "Carriers",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "EMPTY_LIST",
                    "label": null,
                    "type": "KEYWORD",
                    "value": "arrays.create()"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "b1",
          "storeResult": true
        },
        "name": "Start the carrier list",
        "nextElementIds": [],
        "nextGroupIds": [
          "172A1B17-D161-4583-BD7F-57ACB242DABA"
        ],
        "type": "DATA_BUCKET"
      },
      {
        "clientMetadata": {
          "elementId": "data-bucket",
          "isFirstElement": false,
          "blockDefinitionId": "data-bucket",
          "fieldKeys": {
            "Carriers": "51b6efcb-33a4-4c1f-836d-7ae515c68a20"
          },
          "position": {
            "x": 710,
            "y": 49
          }
        },
        "flowElementId": "E175CAEC-E3B5-4B92-B905-CA67FD362D1E",
        "groupId": "172A1B17-D161-4583-BD7F-57ACB242DABA",
        "id": "AAD93106-6A18-41D9-8AFB-F5C4E857B90A",
        "metaInfo": {
          "bucketName": "Default",
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "fields": [
            {
              "name": "Carriers",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Carriers so far",
                    "subPathSegments": [
                      {
                        "key": "list",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "B47C6639-A411-4C0E-8D6B-15C8AB537BAA"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "keepc",
          "storeResult": true
        },
        "name": "Keep the carrier list",
        "nextElementIds": [],
        "nextGroupIds": [],
        "type": "DATA_BUCKET"
      },
      {
        "clientMetadata": {
          "notes": "Gets one load (McLeod order) by its order ID: status, customer, the user who entered it, every stop with its scheduled window and actual arrival and departure, piece count and weight, the customer charges (other charges), and for each movement the carrier, the carrier rep (the movement's dispatcher), the agreed carrier pay and the carrier extra pay, plus the full McLeod records. Optionally adds the customer's contacts and billing contact email.",
          "elementId": "EXTENSION:::SHARED:::default:::mcleod-loadmaster:::getLoad",
          "isFirstElement": true,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Get the load Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::mcleod-loadmaster:::getLoad",
          "legacyElementId": null,
          "methodName": "getLoad",
          "position": {
            "x": 110,
            "y": 40
          }
        },
        "flowElementId": "FA35D931-B1AA-42CB-A4EE-5019F4C799B6",
        "groupId": "172A1B17-D161-4583-BD7F-57ACB242DABA",
        "id": "5689214F-E226-4A1C-AD69-6ABD5381501C",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "orderId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "label": null,
                    "subPathSegments": null,
                    "type": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "value": "172A1B17-D161-4583-BD7F-57ACB242DABA"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "includeCustomerContacts",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "BASIC",
                "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": "getLoad",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Load",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "mcleod-loadmaster",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Get the load",
        "nextElementIds": [
          "B47C6639-A411-4C0E-8D6B-15C8AB537BAA"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Searches FMCSA for carriers whose legal or DBA name matches. Returns each match flattened to one level, with the same fields and true or false flags as Get Carrier by DOT Number. FMCSA returns at most 50 carriers per call; use Start and Size to read further.",
          "elementId": "EXTENSION:::SHARED:::default:::fmcsa:::searchCarriersByName",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Find the carrier at FMCSA Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::fmcsa:::searchCarriersByName",
          "legacyElementId": null,
          "methodName": "searchCarriersByName",
          "position": {
            "x": 413,
            "y": 400
          }
        },
        "flowElementId": "E4FF5384-C574-47AC-A171-8E0BFB486C38",
        "groupId": "D1A66DB4-E267-4BAB-A55E-120602A4298F",
        "id": "A31F9217-B2F7-4D42-A6B4-B52886C04F45",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "name",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Carrier",
                    "subPathSegments": [
                      {
                        "key": "searchName",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "F928FC40-ABE2-44BB-BDA1-943176FB01EE"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "start",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "size",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "NUMBER",
                    "label": null,
                    "type": "INPUT",
                    "value": 50
                  }
                ],
                "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": "searchCarriersByName",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "FMCSA matches",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "fmcsa",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Find the carrier at FMCSA",
        "nextElementIds": [
          "911BB22C-4189-4D60-B922-165A0200D7E7"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Collect the load numbers Result"
          },
          "position": {
            "x": 762,
            "y": 229
          }
        },
        "flowElementId": "4FEC7464-EE1E-476D-89C5-78AC577A93E8",
        "groupId": null,
        "id": "616B3F74-F5C6-4993-9DCE-3F5A87DBDD28",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "inProgress",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Loads in progress",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "3D009110-A7F8-4748-BAA0-BFA7B4FB8203"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "available",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Available loads",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "B18114B0-5E8A-4297-81D5-F540C0DE4EDF"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const ids = [];\n[inProgress, available].forEach(r => (r && Array.isArray(r.loads) ? r.loads : []).forEach(l => { if (l && l.orderId && !ids.includes(l.orderId)) ids.push(String(l.orderId)); }));\nreturn { orderIds: ids };\n"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Active loads",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Collect the load numbers",
        "nextElementIds": [
          "D608AC9A-14BD-4BEA-9F3A-91A1373D16F2"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Note this week's status Result"
          },
          "position": {
            "x": 749,
            "y": 579
          }
        },
        "flowElementId": "5E181768-A555-4929-B203-405EE395957F",
        "groupId": "D1A66DB4-E267-4BAB-A55E-120602A4298F",
        "id": "8F9B7398-EC1A-4C62-BF60-9B17D256D019",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "results",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "EXECUTION_CONTEXT_DATA_BUCKET_VARIABLE",
                    "label": "Default - Results",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_PATH",
                    "value": "executionContext.dataBuckets.Default.Results",
                    "valueSegments": [
                      {
                        "key": "executionContext",
                        "optional": false
                      },
                      {
                        "key": "dataBuckets",
                        "optional": false
                      },
                      {
                        "key": "Default",
                        "optional": false
                      },
                      {
                        "key": "Results",
                        "optional": false
                      }
                    ]
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "carrier",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Carrier",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "F928FC40-ABE2-44BB-BDA1-943176FB01EE"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "match",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Match",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "911BB22C-4189-4D60-B922-165A0200D7E7"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "oos",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "OOS orders",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "C9761C93-9D58-4EA0-A5C6-5C455A1A9B20"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const list = Array.isArray(results) ? results : [];\nconst c = carrier || {};\nconst m = match || {};\nconst r = m.identified ? (m.record || {}) : null;\nconst orders = r && oos && Array.isArray(oos.outOfServiceOrders) ? oos.outOfServiceOrders : [];\nconst row = r ? {\n  id: c.id, name: c.name, loads: c.loads || [],\n  usdot: String(r.dotNumber || ''),\n  fmcsaMatch: 'Matched',\n  allowed: r.isAllowedToOperate === true ? 'Yes' : 'No',\n  authority: (r.hasActiveCommonAuthority === true || r.hasActiveContractAuthority === true) ? 'Active' : 'None',\n  insurance: String(Number(r.bipdInsuranceOnFileUsd || 0)),\n  insuranceRequired: String(Number(r.bipdRequiredAmountUsd || 0)),\n  insuranceRequiredFlag: r.isBipdInsuranceRequired === true,\n  cargo: String(Number(r.cargoInsuranceOnFile || 0) * 1000),\n  bond: String(Number(r.bondInsuranceOnFile || 0) * 1000),\n  outOfService: orders.length ? orders.map(o => o.oosDate + ' ' + (o.oosReasonDescription || o.oosReason || '')).join('; ') : 'None',\n} : {\n  id: c.id, name: c.name, loads: c.loads || [], usdot: '', fmcsaMatch: 'Not matched by name',\n  allowed: '', authority: '', insurance: '', insuranceRequired: '', insuranceRequiredFlag: false, cargo: '', bond: '', outOfService: '',\n  why: m.why || '',\n};\nreturn { list: list.concat([row]) };\n"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Results so far",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Note this week's status",
        "nextElementIds": [
          "4BE5367B-D7BC-4D31-9D3D-02DE9C235624"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Lists loads (McLeod orders) one page at a time, filtered by status, ready to bill flag, customer and delivery date (the scheduled arrival at the consignee stop, in your McLeod server's time). Each load has its stops and customer as McLeod's order search returns them, without charges or movements (use Get Load for those). Pass Next Offset back as Offset for the next page; it is null on the last page.",
          "elementId": "EXTENSION:::SHARED:::default:::mcleod-loadmaster:::listLoads",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "List available loads Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::mcleod-loadmaster:::listLoads",
          "legacyElementId": null,
          "methodName": "listLoads",
          "position": {
            "x": 449,
            "y": 220
          }
        },
        "flowElementId": "73017250-A613-4206-A051-314974BB8D7E",
        "groupId": null,
        "id": "B18114B0-5E8A-4297-81D5-F540C0DE4EDF",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "status",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "A"
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "readyToBill",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "customerId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "deliveryDateFrom",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "deliveryDateTo",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "limit",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "NUMBER",
                    "label": null,
                    "type": "INPUT",
                    "value": 1000
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "offset",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "NUMBER",
                    "label": null,
                    "type": "INPUT",
                    "value": 0
                  }
                ],
                "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": "listLoads",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Available loads",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "mcleod-loadmaster",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "List available loads",
        "nextElementIds": [
          "616B3F74-F5C6-4993-9DCE-3F5A87DBDD28"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "List each carrier once Result"
          },
          "position": {
            "x": 774,
            "y": 399
          }
        },
        "flowElementId": "030A15E0-2E43-459C-9132-A5701F546460",
        "groupId": null,
        "id": "42ECEEB8-D0C2-4B85-8E90-D3186D1D232E",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "carriers",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "EXECUTION_CONTEXT_DATA_BUCKET_VARIABLE",
                    "label": "Default - Carriers",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_PATH",
                    "value": "executionContext.dataBuckets.Default.Carriers",
                    "valueSegments": [
                      {
                        "key": "executionContext",
                        "optional": false
                      },
                      {
                        "key": "dataBuckets",
                        "optional": false
                      },
                      {
                        "key": "Default",
                        "optional": false
                      },
                      {
                        "key": "Carriers",
                        "optional": false
                      }
                    ]
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const by = {};\n(Array.isArray(carriers) ? carriers : []).forEach(c => {\n  if (!by[c.id]) by[c.id] = { id: c.id, name: c.name, loads: [] };\n  if (c.orderId && !by[c.id].loads.includes(c.orderId)) by[c.id].loads.push(c.orderId);\n});\nreturn { carriers: Object.values(by), count: Object.keys(by).length };\n"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Carrier list",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "List each carrier once",
        "nextElementIds": [
          "0C79104C-4355-4F99-9C64-4E515A325858"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": true,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Take the next carrier Result"
          },
          "position": {
            "x": 110,
            "y": 409
          }
        },
        "flowElementId": "E39DCCA9-BD16-4AFE-81A1-0DF53EE0B625",
        "groupId": "D1A66DB4-E267-4BAB-A55E-120602A4298F",
        "id": "F928FC40-ABE2-44BB-BDA1-943176FB01EE",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "item",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "label": null,
                    "subPathSegments": null,
                    "type": "LIST_ITERATOR_CURRENT_ELEMENT",
                    "value": "D1A66DB4-E267-4BAB-A55E-120602A4298F"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const c = item || {};\nconst name = String(c.name || '');\nconst clean = name.replace(/&/g, ' and ').replace(/[^A-Za-z0-9 ]/g, ' ')\n  .replace(/\\b(llc|l l c|inc|incorporated|corp|corporation|co|company|ltd|lp|llp|pllc)\\b/gi, ' ')\n  .replace(/\\s+/g, ' ').trim();\nreturn { id: String(c.id || ''), name, searchName: clean || name, loads: Array.isArray(c.loads) ? c.loads : [] };\n"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Carrier",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Take the next carrier",
        "nextElementIds": [
          "A31F9217-B2F7-4D42-A6B4-B52886C04F45"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Sends messages to Slack channels with optional Block Kit rich layouts. Supports plain text with Slack formatting, or advanced Block Kit JSON for buttons, menus, and interactive elements. Returns the message timestamp and channel ID for later updates or tracking.",
          "elementId": "EXTENSION:::SHARED:::default:::slack:::sendMessageToChannel",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Tell the carrier compliance lead Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::slack:::sendMessageToChannel",
          "legacyElementId": "JS###v1###Slack###sendMessageToChannel",
          "methodName": "sendMessageToChannel",
          "position": {
            "x": 1094,
            "y": 730
          }
        },
        "flowElementId": "C499F3CE-DC5E-43AD-96DC-D56AF6D3A93D",
        "groupId": null,
        "id": "64A2BBC8-5127-43A9-9230-74A770D4391D",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "channelId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ""
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "messageText",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Changes",
                    "subPathSegments": [
                      {
                        "key": "text",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "E2C543D7-3876-4E3F-8B6C-2D73EEEBA9C3"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "threadId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sendAsBot",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "botName",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "botIcon",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "replyBroadcast",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "imageURL",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "blocks",
              "type": "COMPLEX_LIST",
              "value": []
            }
          ],
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "sendMessageToChannel",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Compliance note",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "slack",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Tell the carrier compliance lead",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Pick the exact match Result"
          },
          "position": {
            "x": 758,
            "y": 409
          }
        },
        "flowElementId": "72D52D20-2EC8-464D-9904-C32D54BD4489",
        "groupId": "D1A66DB4-E267-4BAB-A55E-120602A4298F",
        "id": "911BB22C-4189-4D60-B922-165A0200D7E7",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "carriers",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "FMCSA matches",
                    "subPathSegments": [
                      {
                        "key": "carriers",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "A31F9217-B2F7-4D42-A6B4-B52886C04F45"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "name",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Carrier",
                    "subPathSegments": [
                      {
                        "key": "name",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "F928FC40-ABE2-44BB-BDA1-943176FB01EE"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const norm = s => String(s || '').toUpperCase().replace(/&/g, ' AND ').replace(/[^A-Z0-9 ]/g, ' ')\n  .replace(/\\b(LLC|L L C|INC|INCORPORATED|CORP|CORPORATION|CO|COMPANY|LTD|LP|LLP|PLLC|THE)\\b/g, ' ')\n  .replace(/\\s+/g, ' ').trim();\nconst list = Array.isArray(carriers) ? carriers : [];\nconst key = norm(name);\nconst byDot = {};\nlist.filter(c => key && [c.legalName, c.dbaName].map(norm).includes(key)).forEach(c => { byDot[String(c.dotNumber)] = c; });\nconst exact = Object.values(byDot);\nconst identified = exact.length === 1;\nconst rec = identified ? exact[0] : null;\nconst describe = c => c.legalName + (c.dbaName ? ' (DBA ' + c.dbaName + ')' : '') + ', USDOT ' + c.dotNumber + (c.phyCity ? ', ' + c.phyCity + ', ' + (c.phyState || '') : '');\nconst shown = (exact.length ? exact : list).slice(0, 5).map(c => '- ' + describe(c)).join('\\n');\nconst why = exact.length > 1\n  ? 'FMCSA has ' + exact.length + ' carriers with that exact name, so the flow could not tell which one this is.'\n  : 'FMCSA has no carrier with that exact legal or DBA name.';\nreturn {\n  identified,\n  dotNumber: rec ? Number(rec.dotNumber) : 0,\n  record: rec || {},\n  why,\n  candidates: shown,\n};\n"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Match",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Pick the exact match",
        "nextElementIds": [
          "53792344-DA2B-44B2-85BE-665B55C856D6"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Note the carrier Result"
          },
          "position": {
            "x": 410,
            "y": 49
          }
        },
        "flowElementId": "C11BEBA2-1279-4DAB-A52C-BE95AA8C3328",
        "groupId": "172A1B17-D161-4583-BD7F-57ACB242DABA",
        "id": "B47C6639-A411-4C0E-8D6B-15C8AB537BAA",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "carriers",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "EXECUTION_CONTEXT_DATA_BUCKET_VARIABLE",
                    "label": "Default - Carriers",
                    "subPathSegments": null,
                    "type": "EXECUTION_CONTEXT_PATH",
                    "value": "executionContext.dataBuckets.Default.Carriers",
                    "valueSegments": [
                      {
                        "key": "executionContext",
                        "optional": false
                      },
                      {
                        "key": "dataBuckets",
                        "optional": false
                      },
                      {
                        "key": "Default",
                        "optional": false
                      },
                      {
                        "key": "Carriers",
                        "optional": false
                      }
                    ]
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "load",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Load",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "5689214F-E226-4A1C-AD69-6ABD5381501C"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const list = Array.isArray(carriers) ? carriers : [];\nconst moves = load && Array.isArray(load.movements) && load.movements.length ? load.movements : (load && load.carrier ? [{ carrier: load.carrier }] : []);\nconst added = [];\nmoves.forEach(m => {\n  const c = m && m.carrier;\n  if (c && c.id) added.push({ id: String(c.id), name: String(c.name || c.id), orderId: String(load.orderId || '') });\n});\nreturn { list: list.concat(added) };\n"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Carriers so far",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Note the carrier",
        "nextElementIds": [
          "AAD93106-6A18-41D9-8AFB-F5C4E857B90A"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      }
    ],
    "firstElementId": "3D009110-A7F8-4748-BAA0-BFA7B4FB8203",
    "groups": [
      {
        "clientMetadata": {
          "elementId": "list-iterator",
          "isFirstElement": false,
          "blockDefinitionId": "list-iterator",
          "viewport": {
            "x": -70,
            "y": 0,
            "zoom": 1
          },
          "position": {
            "x": 1131,
            "y": 399
          }
        },
        "flowElementId": "9E2705DE-0734-435D-96F5-79FDFE05AA16",
        "groupId": null,
        "id": "172A1B17-D161-4583-BD7F-57ACB242DABA",
        "loopType": "LIST_ITERATOR",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "enabled": true,
          "firstElementId": "5689214F-E226-4A1C-AD69-6ABD5381501C",
          "list": {
            "expression": [
              {
                "id": "ELEMENT_RESULT",
                "label": "Active loads",
                "subPathSegments": [
                  {
                    "key": "orderIds",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "616B3F74-F5C6-4993-9DCE-3F5A87DBDD28"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "onFailElemId": null,
          "resultAlias": "loop1",
          "storeResult": true
        },
        "name": "For each open load",
        "nextElementIds": [
          "42ECEEB8-D0C2-4B85-8E90-D3186D1D232E"
        ],
        "nextGroupIds": [],
        "type": "LOOP"
      },
      {
        "clientMetadata": {
          "elementId": "list-iterator",
          "isFirstElement": false,
          "blockDefinitionId": "list-iterator",
          "viewport": {
            "x": -70,
            "y": -360,
            "zoom": 1
          },
          "position": {
            "x": 123,
            "y": 399
          }
        },
        "flowElementId": "2A921404-02C1-4A2A-9389-41A21F5B6642",
        "groupId": null,
        "id": "D1A66DB4-E267-4BAB-A55E-120602A4298F",
        "loopType": "LIST_ITERATOR",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "enabled": true,
          "firstElementId": "F928FC40-ABE2-44BB-BDA1-943176FB01EE",
          "list": {
            "expression": [
              {
                "id": "ELEMENT_RESULT",
                "label": "Carrier list",
                "subPathSegments": [
                  {
                    "key": "carriers",
                    "optional": false
                  }
                ],
                "type": "ELEMENT_LINK",
                "value": "42ECEEB8-D0C2-4B85-8E90-D3186D1D232E"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "onFailElemId": null,
          "resultAlias": "loop2",
          "storeResult": true
        },
        "name": "For each carrier",
        "nextElementIds": [
          "9D8CFB5D-BA2A-422A-965F-48A13256E1DC"
        ],
        "nextGroupIds": [],
        "type": "LOOP"
      }
    ],
    "id": "3AB82357-98BD-4EA9-87F6-0B7A48EF3FFE",
    "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 ID of the Google Sheet that keeps each week's carrier check results.",
          "error": null,
          "name": "Carrier check sheet",
          "type": "STRING",
          "value": ""
        },
        {
          "description": "The tab in that sheet, the number after gid= in its URL.",
          "error": null,
          "name": "Carrier check tab ID",
          "type": "INT",
          "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:48.215Z"
}
