I have a sheet, which has 4 columns A-D with first name, last name, email, and Group. I want to be able to take a list of users on this sheet and add them all as google contacts in one script.
Each time I run the script it goes through to the 2nd or 3rd row in the sheet and errors with 'Exception: The resource you requested could not be located.'
Any help would be much appreciated. Read a few related topics on the error and calling the new contact ID once created to add the groups, but still not getting any further.
var activeSpreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var activeSheet = activeSpreadsheet.getActiveSheet();
var info1 = activeSheet.getRange("A2:D");
var info2 = info1.getValues();
for (s=0; s<info2.length;s++) {
if (info2[s][0]=="") {
break;
}
var c = ContactsApp.createContact(info2[s][0], info2[s][1], info2[s][2]);
var cid = c.getId();
var ccid = ContactsApp.getContactById(cid);
var gm = ContactsApp.getContactGroup('System Group: My Contacts');
var tg = ContactsApp.getContactGroup(info2[s][3]);
ccid.addToGroup(gm);
ccid.addToGroup(tg);
}
}
