I\'m using the GAS code bellow to add a new contact into Google Contacts (https://contacts.google.com/):
var contact = ContactsApp.createContact(\'Bbbb\', \'C
For me, I have to add them to the ContactGroup named System Group: My Contacts
.
function finishAddingContact(contact) {
var mainGroup = ContactsApp.getContactGroup("System Group: My Contacts");
if(mainGroup)
mainGroup.addContact(contact);
}
Note that getContactGroup(string) is an exact name match.
I recommend inspecting your ContactGroups for system groups, and then selecting the appropriate one from that list. It's probably the one with the most contacts in it:
function inspect() {
var groups = ContactsApp.getContactGroups();
for(var g = 0; g < groups.length; ++g) {
if(groups[g].isSystemGroup()) {
Logger.log(groups[g].getName() + ": " + groups[g].getContacts().length + " members, id=" + groups[g].getId());
}
}
}
Thanks a lot tehhwch.
I used your second code to get the right group ("System Group: My Contacts"), and then:
var contact = ContactsApp.createContact('Wunder', 'Bar', 'excellent@help.com');
var group = ContactsApp.getContactGroup("System Group: My Contacts");
group.addContact(contact);
It works, and the contact is immediately visible in my Android device.