Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script google应用程序脚本的SharedContactApp API_Google Apps Script_Google Workspace_Google Shared Contacts - Fatal编程技术网

Google apps script google应用程序脚本的SharedContactApp API

Google apps script google应用程序脚本的SharedContactApp API,google-apps-script,google-workspace,google-shared-contacts,Google Apps Script,Google Workspace,Google Shared Contacts,全部 我有一个google应用程序脚本,可以在GSuite域中创建共享联系人 Logger.clear(); debug("Begin createSharedContacts"); var rangeDataValues = SpreadsheetApp.getActiveSheet().getRange(dataA1notation).getValues(); var sharedContact = null; var sharedContactCustomField =

全部

我有一个google应用程序脚本,可以在GSuite域中创建共享联系人

  Logger.clear();
  debug("Begin createSharedContacts");
  var rangeDataValues = SpreadsheetApp.getActiveSheet().getRange(dataA1notation).getValues();
  var sharedContact = null;
  var sharedContactCustomField = null;
  var sharedContactAlt1EmailField = null;
  // loop trough all data, but process only the ones with a StudentNr
  for (var i = 0; (i < rangeDataValues.length) && (rangeDataValues[i][0] != ""); i++) {
      var rangeDataValueRow = rangeDataValues[i];
      sharedContact = SharedContactsApp.createContact(rangeDataValueRow[1], rangeDataValueRow[2], "xx@yy.zz");
      sharedContactCustomField = sharedContact.addCustomField("Stamnummer",rangeDataValueRow[0]);
      sharedContactAlt1EmailField = sharedContact.addEmail(ContactsApp.Field.HOME_EMAIL, rangeDataValueRow[8]);
      debug(Object.prototype.toString.call(sharedContactAlt1EmailField));
      debug(JSON.stringify(sharedContactAlt1EmailField));
      sharedContactAlt1EmailField.setDisplayName("("+rangeDataValueRow[6]+") "+rangeDataValueRow[7]+", "+rangeDataValueRow[6]);
      SpreadsheetApp.getActiveSheet().getRange(i+3,5).setValue(sharedContact.getId());
  }
  debug("End createSharedContacts");
关于如何解决这个问题的任何意见

问候
Olivier

我建议您编辑示例代码,使用硬编码数据进行更简单的测试,然后在此处报告结果,包括完整的错误消息和发生错误的行号等。如果您无法复制,则可能会指出数据中的问题。看起来您正在创建联系人并给其提供电子邮件地址但未规定您希望主要发送哪封电子邮件:
TypeError: Cannot find function setAsPrimary  in object [object Object].