Friday, 23 August 2013

How can I improve this code to call Google API less times

How can I improve this code to call Google API less times

I have to sync google contacts with spreadsheet, for this I have to call
API so may time to set values in Google spreadsheet, how can I overcome
this problem to call google API less times or only once ?
var preContacts = group.getContacts();
var rowNo = 2;
for(var y = 0; y < preContacts.length; y++) {
var FNameContact = preContacts[y].getGivenName();
var PhoneNoArray = preContacts[y].getPhones();
var PhoneNoContact = getPhoneNumbers(PhoneNoArray);
var emailArray = preContacts[y].getEmails();
var emailAdressContact = getEmailAddresses(emailArray);
//var customFieldsArray = preContacts.getCustomFields();
sheettab_bulk_cdb.getRange("J"+rowNo).setValue(emailAdressContact);
sheettab_bulk_cdb.getRange("G"+rowNo).setValue(emailAdressContact);
sheettab_bulk_cdb.getRange("F"+rowNo).setValue(emailAdressContact);
sheettab_bulk_cdb.getRange("A"+rowNo).setValue(emailAdressContact);
rowNo++;
}

No comments:

Post a Comment