I have more than 5000 deals in Pipedrive and I want to pull all the deals using Pipedrive integration to google sheet.
I tried some script and successfully pull some data but the problem is Pipedrive has only 500 max limit in each page.
So would like to ask how will I able to loop the pagination and to get all the deals.
please see the script below.
function GetPdriveSalesToday() {
var ss = SpreadsheetApp.openById('xxxxxxxxxxxxxxxxxxxx');
var sheet = ss.getSheetByName("Sheet6");
var lastrow = sheet.getLastRow();
sheet.getRange("Sheet6!A2:C3500").clearContent();
var url = "https://api.pipedrive.com/v1/deals?filter_id=2699&start=1&limit=500&api_token=xxxxxxxxxxxxxxxxxxxx";
var response = UrlFetchApp.fetch(url);
var dataSet = JSON.parse(response.getContentText());
var data;
for (var i = 0; i < dataSet.data.length; i++) {
data = dataSet.data[i];
sheet.appendRow([data.id,data.title,data.e2c4a2838c16e53c6f4cf3b54ac5bfe253310a7a]).getRange(lastrow +1,1);
}
}