将联系人添加到Google联系人的主联系人列表(未隐藏) [英] Add contacts to Google Contacts' main Contacts list (not hidden)

查看:230
本文介绍了将联系人添加到Google联系人的主联系人列表(未隐藏)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用GAS代码将新联系人添加到Google通讯录中( https://contacts.google / b>

  var contact = ContactsApp.createContact('Bbbb','Cccc','mymail @ mails.com')。addUrl(ContactsApp.Field.WORK_WEBSITE,'https://sites.google.com/site/diccionarioie'); 

代码完美地工作,但对于单个细节:它将新联系人添加到隐藏列表中,而不是到主要或可见的«联系人»列表。



我知道这是可行的,因为当我使用查找框搜索新创建的联系人时,联系人»列表。我需要从一开始就在主要的«联系人»列表中创建它,否则我将不得不使用创建的每个联系人来手动使用添加到联系人图标(我计划添加数以千计的联系人)。



谢谢。

解决方案

对我来说,我必须添加它们到ContactGroup,名为系统组:我的联系人

 函数finishAddingContact联系人){
var mainGroup = ContactsApp.getContactGroup(System Group:My Contacts);
if(mainGroup)
mainGroup.addContact(contact);
}

请注意 getContactGroup(string) 是一个确切的名字匹配。 / p>

我建议检查您的ContactGroups中的系统组,然后从该列表中选择适当的一个。这可能是其中联系最多的一个:

  function inspect(){
var groups = ContactsApp.getContactGroups (); (group)[g] .isSystemGroup()){
Logger.log(groups [g,group
) ] .getName()+:+ groups [g] .getContacts()。length +members,id =+ groups [g] .getId());
}
}
}


I'm using the GAS code bellow to add a new contact into Google Contacts (https://contacts.google.com/):

var contact = ContactsApp.createContact('Bbbb', 'Cccc', 'mymail@mails.com').addUrl(ContactsApp.Field.WORK_WEBSITE, 'https://sites.google.com/site/diccionarioie');

The code works perfectly but for a single detail: it adds the new contact to a hidden list and not to the main or visible «Contacts» list.

I know it works because when I use the lookup box to search for the newly created contact it's there, in the «Other contacts» list. I need it to be created in the main «Contacts» list from the beginning, otherwise I would have to do it manually using the «Add to contacts» icon with every contact created (I'm planning to add some thousands of contacts.)

Thanks.

解决方案

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());
    }
  }
}

这篇关于将联系人添加到Google联系人的主联系人列表(未隐藏)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆