I’m trying to collect contact information into a google sheets, and I can get only the normal fields, but I have 2 custom fields, that is not listed here, how can I get this fields ?
Here my source code.
any ideas?
I’m using Scripts for google sheets.
function doGetContacts(e) {
return getContacts(e);
}
function getContacts(e){
try {
var responseC = UrlFetchApp.fetch(URL+'/contacts?listid=28', options);
var dataC = responseC.getContentText();
var jsonC = JSON.parse(dataC);
var contacts = jsonC['contacts'];
var contactsData = [];
for (var i = 0; i < contacts.length; i++) {
contactsData.push([
contacts[i]["email"],
contacts[i]["firstName"],
contacts[i]["phone"],
contacts[i]["id"],
]);
}
var numRows = contactsData.length;
var numCols = contactsData[0].length;
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName('Sheet1');
sheet.getRange('A2:M').clearContent();
SpreadsheetApp.flush();
Utilities.sleep(500);
sheet.getRange(2,1,numRows,numCols).setValues(contactsData);
}
catch (error) {
Logger.log(error);
}
}