@יוסי-יוסי-0 כתב בבקשה | סנכרון גוגל שייטס לאנשי קשר:
מישהו יודע מנסיון האם קיים אופיה כזו?
של סנכרון אנשי קשר של גוגל ע"י נתונים בטבלה בגוגל שייטס?
אפשרי עם קוד בגוגל סקריפט עם טריגר להפעלה בעת פתיחת השיטס או בכל שינוי או כמה פעמים ביום.
דוגמא לקוד לטבלא שיש לו כותרות "First Name", "Last Name", "Email", ו-"Phone"
function syncContacts() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var data = sheet.getDataRange().getValues();
var headers = data[0];
for (var i = 1; i < data.length; i++) {
var row = data[i];
var contact = {
givenName: row[headers.indexOf("First Name")],
familyName: row[headers.indexOf("Last Name")],
email: row[headers.indexOf("Email")],
phone: row[headers.indexOf("Phone")]
};
createOrUpdateContact(contact);
}
}
function createOrUpdateContact(contact) {
var contactsByEmail = ContactsApp.getContactsByEmailAddress(contact.email);
var contactsByPhone = contact.phone ? ContactsApp.getContactsByPhone(contact.phone) : [];
var existingContact = contactsByEmail.length > 0 ? contactsByEmail[0] :
contactsByPhone.length > 0 ? contactsByPhone[0] : null;
if (existingContact) {
// עדכון איש קשר קיים
existingContact.setGivenName(contact.givenName);
existingContact.setFamilyName(contact.familyName);
if (contact.phone) {
var phones = existingContact.getPhones(ContactsApp.Field.MOBILE_PHONE);
if (phones.length > 0) {
phones[0].setValue(contact.phone);
} else {
existingContact.addPhone(ContactsApp.Field.MOBILE_PHONE, contact.phone);
}
}
} else {
// יצירת איש קשר חדש
var newContact = ContactsApp.createContact(contact.givenName, contact.familyName, contact.email);
if (contact.phone) {
newContact.addPhone(ContactsApp.Field.MOBILE_PHONE, contact.phone);
}
}
}