全部
我有一个谷歌应用程序脚本来在 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");
当我执行此和平操作代码时,出现错误:
TypeError: Cannot find function setAsPrimary in object [object Object].
关于如何解决这个问题的任何意见。
亲切的问候奥利维尔