{
  "name": "Обмен n8n с 1С через OData: заказы в трекер",
  "nodes": [
    {
      "parameters": {
        "content": "## Заказы из 1С → задачи в трекере\nКаждые 15 минут в рабочее время забирает проведённые заказы за сутки без пометки «Передан», создаёт задачу и ставит пометку в комментарий заказа (PATCH меняет одно поле и не трогает остальные).\n\nПосле импорта: адрес публикации OData, логин и пароль 1С (Basic Auth), адрес и токен трекера.",
        "width": 560,
        "height": 220
      },
      "id": "b6a84d49-e76a-56d2-9eb5-b76564ccaca6",
      "name": "Заметка 19fa84",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -40,
        -260
      ]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 */15 9-18 * * 1-5"
            }
          ]
        }
      },
      "id": "a774a63f-26f0-5236-a730-6e1a5b526945",
      "name": "Каждые 15 минут",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "url": "https://1c.example.ru/base/odata/standard.odata/Document_ЗаказКлиента",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBasicAuth",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "$format",
              "value": "json"
            },
            {
              "name": "$filter",
              "value": "=Posted eq true and Date ge datetime'{{ $now.minus({days: 1}).toFormat(\"yyyy-MM-dd'T'HH:mm:ss\") }}' and substringof('Передан', Комментарий) eq false"
            },
            {
              "name": "$select",
              "value": "Ref_Key,Number,Date,СуммаДокумента,Комментарий"
            },
            {
              "name": "$top",
              "value": "100"
            }
          ]
        },
        "options": {}
      },
      "id": "06386d36-c412-5151-b685-f90c0d6e2375",
      "name": "Заказы из 1С",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        220,
        0
      ]
    },
    {
      "parameters": {
        "fieldToSplitOut": "value",
        "options": {}
      },
      "id": "19f555db-024a-5a19-ae75-fe39588b9305",
      "name": "По одному заказу",
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        440,
        0
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://tracker.example.ru/api/tasks",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"title\": \"Заказ {{ $json.Number }} от {{ $json.Date.slice(0, 10) }}\",\n  \"description\": \"Сумма: {{ $json.СуммаДокумента }} ₽\",\n  \"external_id\": \"{{ $json.Ref_Key }}\"\n}",
        "options": {}
      },
      "id": "d078a379-64a3-5112-973c-4085dc74cf70",
      "name": "Задача в трекере",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        660,
        0
      ]
    },
    {
      "parameters": {
        "method": "PATCH",
        "url": "=https://1c.example.ru/base/odata/standard.odata/Document_ЗаказКлиента(guid'{{ $('По одному заказу').item.json.Ref_Key }}')?$format=json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBasicAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"Комментарий\": \"{{ $('По одному заказу').item.json.Комментарий }} Передан в трекер\"\n}",
        "options": {}
      },
      "id": "912fb90f-209f-580e-8aa5-9cf3d0cbbdc8",
      "name": "Пометить в 1С",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        880,
        0
      ]
    }
  ],
  "connections": {
    "Каждые 15 минут": {
      "main": [
        [
          {
            "node": "Заказы из 1С",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Заказы из 1С": {
      "main": [
        [
          {
            "node": "По одному заказу",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "По одному заказу": {
      "main": [
        [
          {
            "node": "Задача в трекере",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Задача в трекере": {
      "main": [
        [
          {
            "node": "Пометить в 1С",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "active": false,
  "meta": {
    "templateCredsSetupCompleted": false,
    "source": "promtbaza.com/voprosy/shablony-n8n"
  }
}