Loop issues on a http request

Hi, I’m updating the format of my persons in pipedrive but in the loop doesn’t work well I think my functions needs to return something different here is my example:

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        110,
        460
      ]
    },
    {
      "parameters": {
        "conditions": {
          "boolean": [],
          "number": [
            {
              "value1": "= {{$json[\"index\"]}}",
              "operation": "larger"
            }
          ]
        }
      },
      "name": "IF",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        710,
        310
      ]
    },
    {
      "parameters": {
        "values": {
          "boolean": [],
          "string": [
            {
              "name": "index",
              "value": "={{$node[\"Get deals from Pipedrive\"].json[\"additional_data\"][\"pagination\"][\"next_start\"]}}"
            }
          ]
        },
        "options": {}
      },
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        490,
        460
      ]
    },
    {
      "parameters": {
        "url": "=https://vation.pipedrive.com/v1/persons?api_token=testToken&start={{$node[\"Set\"].json[\"index\"] || 0}}&limit=30",
        "allowUnauthorizedCerts": true,
        "jsonParameters": true,
        "options": {}
      },
      "name": "Get deals from Pipedrive",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        300,
        460
      ],
      "color": "#000000"
    },
    {
      "parameters": {
        "resource": "person",
        "operation": "update",
        "personId": "={{$json[\"id\"]}}",
        "updateFields": {
          "phone": [
            "={{$json[\"phone\"][0][\"value\"]}}"
          ]
        }
      },
      "name": "Pipedrive1",
      "type": "n8n-nodes-base.pipedrive",
      "typeVersion": 1,
      "position": [
        1000,
        460
      ],
      "credentials": {
        "pipedriveApi": "Pipedrive SANDBOX"
      },
      "continueOnFail": true
    },
    {
      "parameters": {
        "functionCode": "const data = items[0].json.data;\nlet result = [];\n\nfor(person of data) {\n    result.push({ json: person });\n};\n\nreturn result;"
      },
      "name": "Transform Input",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        660,
        460
      ]
    },
    {
      "parameters": {
        "functionCode": "/**\n * @constructor\n * @param {string|number} phoneNumber - The telephone number.\n */\nconst teleFixer = function (phoneNumber) {\n  const stringPhone = String(phoneNumber).replace(/ /g,'').replace('(','').replace(')','');\n\n  switch (stringPhone) {\n    case (stringPhone.match(/^00490/) || {}).input:\n      return stringPhone.replace(\"00490\", \"+49\");\n      break;\n    case (stringPhone.match(/^0049/) || {}).input:\n      return stringPhone.replace(\"0049\", \"+49\");\n      break;\n    case (stringPhone.match(/^01/) || {}).input:\n      return stringPhone.replace(\"0\", \"+49\");\n      break;\n    case (stringPhone.match(/^1/) || {}).input:\n      return \"+49\" + stringPhone;\n      break;\n    case (stringPhone.match(/^491/) || {}).input:\n      return stringPhone.replace(\"49\", \"+49\");\n      break;\n    case (stringPhone.match(/^490/) || {}).input:\n      return stringPhone.replace(\"490\", \"+49\");\n      break;\n    case (stringPhone.match(/^\\+490/) || {}).input:\n      return stringPhone.replace(\"+490\", \"+49\");\n      break;\n\n    // Austrian regexp\n    case (stringPhone.match(/^00430/) || {}).input:\n      return stringPhone.replace(\"00430\", \"+43\");\n      break;\n    case (stringPhone.match(/^0043/) || {}).input:\n      return stringPhone.replace(\"0043\", \"+43\");\n      break;\n    case (stringPhone.match(/^06/) || {}).input:\n      return stringPhone.replace(\"0\", \"+43\");\n      break;\n    case (stringPhone.match(/^6/) || {}).input:\n      return \"+43\" + stringPhone;\n      break;\n    case (stringPhone.match(/^436/) || {}).input:\n      return stringPhone.replace(\"43\", \"+43\");\n      break;\n    case (stringPhone.match(/^430/) || {}).input:\n      return stringPhone.replace(\"430\", \"+43\");\n      break;\n    case (stringPhone.match(/^\\+430/) || {}).input:\n      return stringPhone.replace(\"+430\", \"+43\");\n      break;\n\n    // Swiss regexp\n    case (stringPhone.match(/^00410/) || {}).input:\n      return stringPhone.replace(\"00410\", \"+41\");\n      break;\n    case (stringPhone.match(/^0041/) || {}).input:\n      return stringPhone.replace(\"0041\", \"+41\");\n      break;\n    case (stringPhone.match(/^07/) || {}).input:\n      return stringPhone.replace(\"0\", \"+41\");\n      break;\n    case (stringPhone.match(/^7/) || {}).input:\n      return \"+41\" + stringPhone;\n      break;\n    case (stringPhone.match(/^417/) || {}).input:\n      return stringPhone.replace(\"41\", \"+41\");\n      break;\n    case (stringPhone.match(/^410/) || {}).input:\n      return stringPhone.replace(\"410\", \"+41\");\n      break;\n    case (stringPhone.match(/^\\+410/) || {}).input:\n      return stringPhone.replace(\"+410\", \"+41\");\n      break;\n\n    // Default\n    default:\n      return stringPhone;\n      break;\n  }\n};\n\nitems[0].json.phone[0].value = teleFixer(items[0].json.phone[0].value);\nreturn items;"
      },
      "name": "Format Phone Number",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        830,
        460
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Get deals from Pipedrive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF": {
      "main": [
        [
          {
            "node": "Get deals from Pipedrive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set": {
      "main": [
        [
          {
            "node": "IF",
            "type": "main",
            "index": 0
          },
          {
            "node": "Transform Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get deals from Pipedrive": {
      "main": [
        [
          {
            "node": "Set",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Transform Input": {
      "main": [
        [
          {
            "node": "Format Phone Number",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Phone Number": {
      "main": [
        [
          {
            "node": "Pipedrive1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Hey @Juan_Gabriel_Fraire!

If I understood correctly, you are trying to update the phone number (format them correctly). I have created a workflow that might help you with your problem. I am using the Split In Batches node, which will split the information of each user. The information of each user is then passed one by one to the next nodes. Once the PipeDrive node finishes the execution, the next batch of data is passed to the nodes.

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        0,
        300
      ]
    },
    {
      "parameters": {
        "url": "=https://test.pipedrive.com/v1/persons?api_token=test&start=0&limit=30",
        "allowUnauthorizedCerts": true,
        "jsonParameters": true,
        "options": {}
      },
      "name": "Get deals from Pipedrive",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        200,
        300
      ],
      "color": "#000000"
    },
    {
      "parameters": {
        "resource": "person",
        "operation": "update",
        "personId": "={{$json[\"id\"]}}",
        "updateFields": {
          "phone": [
            "={{$json[\"phone\"][0][\"value\"]}}"
          ]
        }
      },
      "name": "Pipedrive1",
      "type": "n8n-nodes-base.pipedrive",
      "typeVersion": 1,
      "position": [
        950,
        100
      ],
      "credentials": {
        "pipedriveApi": "pipedrive-test"
      },
      "continueOnFail": true
    },
    {
      "parameters": {
        "functionCode": "/**\n * @constructor\n * @param {string|number} phoneNumber - The telephone number.\n */\nconst teleFixer = function (phoneNumber) {\n  const stringPhone = String(phoneNumber).replace(/ /g,'').replace('(','').replace(')','');\n\n  switch (stringPhone) {\n    case (stringPhone.match(/^00490/) || {}).input:\n      return stringPhone.replace(\"00490\", \"+49\");\n      break;\n    case (stringPhone.match(/^0049/) || {}).input:\n      return stringPhone.replace(\"0049\", \"+49\");\n      break;\n    case (stringPhone.match(/^01/) || {}).input:\n      return stringPhone.replace(\"0\", \"+49\");\n      break;\n    case (stringPhone.match(/^1/) || {}).input:\n      return \"+49\" + stringPhone;\n      break;\n    case (stringPhone.match(/^491/) || {}).input:\n      return stringPhone.replace(\"49\", \"+49\");\n      break;\n    case (stringPhone.match(/^490/) || {}).input:\n      return stringPhone.replace(\"490\", \"+49\");\n      break;\n    case (stringPhone.match(/^\\+490/) || {}).input:\n      return stringPhone.replace(\"+490\", \"+49\");\n      break;\n\n    // Austrian regexp\n    case (stringPhone.match(/^00430/) || {}).input:\n      return stringPhone.replace(\"00430\", \"+43\");\n      break;\n    case (stringPhone.match(/^0043/) || {}).input:\n      return stringPhone.replace(\"0043\", \"+43\");\n      break;\n    case (stringPhone.match(/^06/) || {}).input:\n      return stringPhone.replace(\"0\", \"+43\");\n      break;\n    case (stringPhone.match(/^6/) || {}).input:\n      return \"+43\" + stringPhone;\n      break;\n    case (stringPhone.match(/^436/) || {}).input:\n      return stringPhone.replace(\"43\", \"+43\");\n      break;\n    case (stringPhone.match(/^430/) || {}).input:\n      return stringPhone.replace(\"430\", \"+43\");\n      break;\n    case (stringPhone.match(/^\\+430/) || {}).input:\n      return stringPhone.replace(\"+430\", \"+43\");\n      break;\n\n    // Swiss regexp\n    case (stringPhone.match(/^00410/) || {}).input:\n      return stringPhone.replace(\"00410\", \"+41\");\n      break;\n    case (stringPhone.match(/^0041/) || {}).input:\n      return stringPhone.replace(\"0041\", \"+41\");\n      break;\n    case (stringPhone.match(/^07/) || {}).input:\n      return stringPhone.replace(\"0\", \"+41\");\n      break;\n    case (stringPhone.match(/^7/) || {}).input:\n      return \"+41\" + stringPhone;\n      break;\n    case (stringPhone.match(/^417/) || {}).input:\n      return stringPhone.replace(\"41\", \"+41\");\n      break;\n    case (stringPhone.match(/^410/) || {}).input:\n      return stringPhone.replace(\"410\", \"+41\");\n      break;\n    case (stringPhone.match(/^\\+410/) || {}).input:\n      return stringPhone.replace(\"+410\", \"+41\");\n      break;\n\n    // Default\n    default:\n      return stringPhone;\n      break;\n  }\n};\n\nitems[0].json.phone[0].value = teleFixer(items[0].json.phone[0].value);\nreturn items;"
      },
      "name": "Format Phone Number",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        800,
        300
      ]
    },
    {
      "parameters": {
        "batchSize": 1,
        "options": {}
      },
      "name": "SplitInBatches",
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 1,
      "position": [
        600,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "const data = items[0].json.data;\nlet result = [];\n\nfor(person of data) {\n    result.push({ json: person });\n};\n\nreturn result;"
      },
      "name": "Transform Input",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        400,
        300
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Get deals from Pipedrive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get deals from Pipedrive": {
      "main": [
        [
          {
            "node": "Transform Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pipedrive1": {
      "main": [
        [
          {
            "node": "SplitInBatches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Phone Number": {
      "main": [
        [
          {
            "node": "Pipedrive1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SplitInBatches": {
      "main": [
        [
          {
            "node": "Format Phone Number",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Transform Input": {
      "main": [
        [
          {
            "node": "SplitInBatches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
} 

Hope this helps! Let me know if have any doubts with this solution. :slightly_smiling_face:

@harshil1712, yes this workflow is cool and works fine but once I loop over the http is not executed a second time with the next 30 people.

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        110,
        460
      ]
    },
    {
      "parameters": {
        "conditions": {
          "boolean": [],
          "number": [
            {
              "value1": "= {{$json[\"index\"]}}",
              "operation": "larger"
            }
          ]
        }
      },
      "name": "IF",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        660,
        270
      ]
    },
    {
      "parameters": {
        "values": {
          "boolean": [],
          "string": [
            {
              "name": "index",
              "value": "={{$node[\"Get people from Pipedrive\"].json[\"additional_data\"][\"pagination\"][\"next_start\"]}}"
            }
          ]
        },
        "options": {}
      },
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        430,
        270
      ]
    },
    {
      "parameters": {
        "functionCode": "/**\n * @constructor\n * @param {string|number} phoneNumber - The telephone number.\n */\nconst teleFixer = function (phoneNumber) {\n  const stringPhone = String(phoneNumber).replace(/ /g,'').replace('(','').replace(')','');\n\n  switch (stringPhone) {\n    case (stringPhone.match(/^00490/) || {}).input:\n      return stringPhone.replace(\"00490\", \"+49\");\n      break;\n    case (stringPhone.match(/^0049/) || {}).input:\n      return stringPhone.replace(\"0049\", \"+49\");\n      break;\n    case (stringPhone.match(/^01/) || {}).input:\n      return stringPhone.replace(\"0\", \"+49\");\n      break;\n    case (stringPhone.match(/^1/) || {}).input:\n      return \"+49\" + stringPhone;\n      break;\n    case (stringPhone.match(/^491/) || {}).input:\n      return stringPhone.replace(\"49\", \"+49\");\n      break;\n    case (stringPhone.match(/^490/) || {}).input:\n      return stringPhone.replace(\"490\", \"+49\");\n      break;\n    case (stringPhone.match(/^\\+490/) || {}).input:\n      return stringPhone.replace(\"+490\", \"+49\");\n      break;\n\n    // Austrian regexp\n    case (stringPhone.match(/^00430/) || {}).input:\n      return stringPhone.replace(\"00430\", \"+43\");\n      break;\n    case (stringPhone.match(/^0043/) || {}).input:\n      return stringPhone.replace(\"0043\", \"+43\");\n      break;\n    case (stringPhone.match(/^06/) || {}).input:\n      return stringPhone.replace(\"0\", \"+43\");\n      break;\n    case (stringPhone.match(/^6/) || {}).input:\n      return \"+43\" + stringPhone;\n      break;\n    case (stringPhone.match(/^436/) || {}).input:\n      return stringPhone.replace(\"43\", \"+43\");\n      break;\n    case (stringPhone.match(/^430/) || {}).input:\n      return stringPhone.replace(\"430\", \"+43\");\n      break;\n    case (stringPhone.match(/^\\+430/) || {}).input:\n      return stringPhone.replace(\"+430\", \"+43\");\n      break;\n\n    // Swiss regexp\n    case (stringPhone.match(/^00410/) || {}).input:\n      return stringPhone.replace(\"00410\", \"+41\");\n      break;\n    case (stringPhone.match(/^0041/) || {}).input:\n      return stringPhone.replace(\"0041\", \"+41\");\n      break;\n    case (stringPhone.match(/^07/) || {}).input:\n      return stringPhone.replace(\"0\", \"+41\");\n      break;\n    case (stringPhone.match(/^7/) || {}).input:\n      return \"+41\" + stringPhone;\n      break;\n    case (stringPhone.match(/^417/) || {}).input:\n      return stringPhone.replace(\"41\", \"+41\");\n      break;\n    case (stringPhone.match(/^410/) || {}).input:\n      return stringPhone.replace(\"410\", \"+41\");\n      break;\n    case (stringPhone.match(/^\\+410/) || {}).input:\n      return stringPhone.replace(\"+410\", \"+41\");\n      break;\n\n    // Default\n    default:\n      return stringPhone;\n      break;\n  }\n};\n\nitems[0].json.phone[0].value = teleFixer(items[0].json.phone[0].value);\nreturn items;"
      },
      "name": "Format Phone Number",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        960,
        500
      ]
    },
    {
      "parameters": {
        "batchSize": 1,
        "options": {}
      },
      "name": "SplitInBatches",
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 1,
      "position": [
        760,
        500
      ]
    },
    {
      "parameters": {
        "functionCode": "const data = items[0].json.data;\nlet result = [];\n\nfor(person of data) {\n    result.push({ json: person });\n};\n\nreturn result;"
      },
      "name": "Transform Input",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        560,
        500
      ]
    },
    {
      "parameters": {
        "resource": "person",
        "operation": "update",
        "personId": "={{$json[\"id\"]}}",
        "updateFields": {
          "phone": [
            "={{$json[\"phone\"][0][\"value\"]}}"
          ]
        }
      },
      "name": "Pipedrive1",
      "type": "n8n-nodes-base.pipedrive",
      "typeVersion": 1,
      "position": [
        1110,
        300
      ],
      "credentials": {
        "pipedriveApi": "Pipedrive Prod"
      },
      "continueOnFail": true
    },
    {
      "parameters": {
        "url": "=https://vation.pipedrive.com/v1/persons?api_token=testToken&start={{$node[\"Set\"].json[\"index\"] || 0}}&limit=30",
        "allowUnauthorizedCerts": true,
        "jsonParameters": true,
        "options": {}
      },
      "name": "Get people from Pipedrive",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        310,
        470
      ],
      "color": "#000000"
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Get people from Pipedrive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF": {
      "main": [
        [
          {
            "node": "Get people from Pipedrive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set": {
      "main": [
        [
          {
            "node": "IF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Phone Number": {
      "main": [
        [
          {
            "node": "Pipedrive1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SplitInBatches": {
      "main": [
        [
          {
            "node": "Format Phone Number",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Transform Input": {
      "main": [
        [
          {
            "node": "SplitInBatches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pipedrive1": {
      "main": [
        [
          {
            "node": "SplitInBatches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get people from Pipedrive": {
      "main": [
        [
          {
            "node": "Transform Input",
            "type": "main",
            "index": 0
          },
          {
            "node": "Set",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Hey @Juan_Gabriel_Fraire, is there a particular reason you are addind the limit parameter at the end of the URL? I looked at the Pipedrive API Reference and the limit parameter is optional. Can you try making a request without the limit parameter, and see if you’re getting the desired output?

If all the users are returned then the workflow I shared earlier will work!

Let me know what results you get.

@harshil1712 they have a default limit of 100 and we have thousands of customers already. I added 30 because was better for debuggin purposes.

@harshil1712 looks like the node Split needs to be reset can I get some how if is looping to reset the node in every loop?

It should actually be possible to do that simpler like that:

So simply request all the people at once (or for testing less, set it now to 10 but you can later set “Return All”). Then split them in batches of whatever you want (in my example I did set that to 5) and then “fix” the phone number of 5 people at a time.

Here the workflow:

{
  "nodes": [
    {
      "parameters": {
        "batchSize": 5,
        "options": {}
      },
      "name": "SplitInBatches",
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 1,
      "position": [
        1050,
        -250
      ]
    },
    {
      "parameters": {
        "resource": "person",
        "operation": "update",
        "personId": "={{$json[\"id\"]}}",
        "updateFields": {
          "phone": [
            "={{$json[\"phone\"][0][\"value\"]}}"
          ]
        }
      },
      "name": "Pipedrive1",
      "type": "n8n-nodes-base.pipedrive",
      "typeVersion": 1,
      "position": [
        1450,
        -150
      ],
      "credentials": {
        "pipedriveApi": "Pipedrive Prod"
      },
      "continueOnFail": true
    },
    {
      "parameters": {
        "resource": "person",
        "operation": "getAll",
        "limit": 10,
        "additionalFields": {}
      },
      "name": "Pipedrive3",
      "type": "n8n-nodes-base.pipedrive",
      "typeVersion": 1,
      "position": [
        850,
        -250
      ],
      "credentials": {
        "pipedriveApi": ""
      }
    },
    {
      "parameters": {
        "functionCode": "/**\n * @constructor\n * @param {string|number} phoneNumber - The telephone number.\n */\nconst teleFixer = function (phoneNumber) {\n  const stringPhone = String(phoneNumber).replace(/ /g,'').replace('(','').replace(')','');\n\n  switch (stringPhone) {\n    case (stringPhone.match(/^00490/) || {}).input:\n      return stringPhone.replace(\"00490\", \"+49\");\n      break;\n    case (stringPhone.match(/^0049/) || {}).input:\n      return stringPhone.replace(\"0049\", \"+49\");\n      break;\n    case (stringPhone.match(/^01/) || {}).input:\n      return stringPhone.replace(\"0\", \"+49\");\n      break;\n    case (stringPhone.match(/^1/) || {}).input:\n      return \"+49\" + stringPhone;\n      break;\n    case (stringPhone.match(/^491/) || {}).input:\n      return stringPhone.replace(\"49\", \"+49\");\n      break;\n    case (stringPhone.match(/^490/) || {}).input:\n      return stringPhone.replace(\"490\", \"+49\");\n      break;\n    case (stringPhone.match(/^\\+490/) || {}).input:\n      return stringPhone.replace(\"+490\", \"+49\");\n      break;\n\n    // Austrian regexp\n    case (stringPhone.match(/^00430/) || {}).input:\n      return stringPhone.replace(\"00430\", \"+43\");\n      break;\n    case (stringPhone.match(/^0043/) || {}).input:\n      return stringPhone.replace(\"0043\", \"+43\");\n      break;\n    case (stringPhone.match(/^06/) || {}).input:\n      return stringPhone.replace(\"0\", \"+43\");\n      break;\n    case (stringPhone.match(/^6/) || {}).input:\n      return \"+43\" + stringPhone;\n      break;\n    case (stringPhone.match(/^436/) || {}).input:\n      return stringPhone.replace(\"43\", \"+43\");\n      break;\n    case (stringPhone.match(/^430/) || {}).input:\n      return stringPhone.replace(\"430\", \"+43\");\n      break;\n    case (stringPhone.match(/^\\+430/) || {}).input:\n      return stringPhone.replace(\"+430\", \"+43\");\n      break;\n\n    // Swiss regexp\n    case (stringPhone.match(/^00410/) || {}).input:\n      return stringPhone.replace(\"00410\", \"+41\");\n      break;\n    case (stringPhone.match(/^0041/) || {}).input:\n      return stringPhone.replace(\"0041\", \"+41\");\n      break;\n    case (stringPhone.match(/^07/) || {}).input:\n      return stringPhone.replace(\"0\", \"+41\");\n      break;\n    case (stringPhone.match(/^7/) || {}).input:\n      return \"+41\" + stringPhone;\n      break;\n    case (stringPhone.match(/^417/) || {}).input:\n      return stringPhone.replace(\"41\", \"+41\");\n      break;\n    case (stringPhone.match(/^410/) || {}).input:\n      return stringPhone.replace(\"410\", \"+41\");\n      break;\n    case (stringPhone.match(/^\\+410/) || {}).input:\n      return stringPhone.replace(\"+410\", \"+41\");\n      break;\n\n    // Default\n    default:\n      return stringPhone;\n      break;\n  }\n};\n\n\nitems.forEach(item => {\n  item.json.phone[0].value = teleFixer(item.json.phone[0].value);\n})\n\nreturn items;\n"
      },
      "name": "Format Phone Number",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        1250,
        -250
      ]
    }
  ],
  "connections": {
    "SplitInBatches": {
      "main": [
        [
          {
            "node": "Format Phone Number",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pipedrive1": {
      "main": [
        [
          {
            "node": "SplitInBatches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pipedrive3": {
      "main": [
        [
          {
            "node": "SplitInBatches",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Phone Number": {
      "main": [
        [
          {
            "node": "Pipedrive1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}