I’m trying to load a group and then get everyone first and last name. In the debugger it looks like the group is loaded successfully but when I get down to extracting out the users first and last name I get an error that says, “We’re sorry, a server error occurred. Please wait a bit and try again“.
I’m looking at the documentation for the contact class and it seems like I’m doing it right but the error makes me feel like I’m missing something.
My code:
var distrogroup;
var groups = ContactsApp.getContactGroups();
for (group in groups) {
var tmp = groups[group].getGroupName();
if (groups[group].getGroupName() == 'Phone Bill') {
distrogroup = ContactsApp.getContactsByGroup(groups[group]);
}
}
for (contact in distrogroup) {
var lastname = distrogroup[contact].getFamilyName();
var firstname = distrogroup[contact].getGivenName();
}
Are you wanting to return an array of first and last names? So replacing the last for loop with:
Also, probably nothing to do with the error, but I wonder if the first section of the code could be simplified to:
https://developers.google.com/apps-script/class_contactsapp#getContactGroup