// Logs the address for the 'Home Address' field for contact 'John Doe'.// Can be used similarly for other fields that contain addresses.constcontacts=ContactsApp.getContactsByName('John Doe');consthomeAddress=contacts[0].getAddresses(ContactsApp.Field.HOME_ADDRESS);Logger.log(homeAddress[0].getAddress());
חזרה
String — הכתובת כמחרוזת
אישור
סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:
https://www.google.com/m8/feeds
getLabel()
מחזירה את התווית של השדה הזה. יכול להיות שזה שדה, שדה מורחב או מחרוזת.
// Logs the label for all the address fields associated with contact// 'John Doe'. This method can be similarly called for any field that has// a label.constcontacts=ContactsApp.getContactsByName('John Doe');constaddressFields=contacts[0].getAddresses();for(leti=0;i < addressFields.length;i++){Logger.log(addressFields[i].getLabel());}
חזרה
Object — התווית של השדה הזה
אישור
סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:
https://www.google.com/m8/feeds
isPrimary()
הפונקציה מחזירה אם זה ערך השדה הראשי.
// Logs whether or not the first address field associated with contact// 'John Doe' is labeled as primary. This method can be similarly called// for any field.constcontacts=ContactsApp.getContactsByName('John Doe');constaddressFields=contacts[0].getAddresses();Logger.log(addressFields[0].isPrimary());
חזרה
Boolean – האם זה ראשי
אישור
סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:
https://www.google.com/m8/feeds
setAddress(address)
מגדיר את הכתובת של השדה הזה.
// Sets the address for the 'Home Address' field for contact 'John Doe'.// Can be used similarly for other fields that contain addresses.constcontacts=ContactsApp.getContactsByName('John Doe');consthomeAddress=contacts[0].getAddresses(ContactsApp.Field.HOME_ADDRESS);homeAddress[0].setAddress('123 Main St, Raleigh, NC, 27601');
סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:
https://www.google.com/m8/feeds
setAsPrimary()
הגדרת השדה הזה כראשי.
// Sets the first address field associated with contact 'John Doe'// as primary. This method can be similarly called for any field.constcontacts=ContactsApp.getContactsByName('John Doe');constaddressFields=contacts[0].getAddresses();addressFields[0].setAsPrimary();
סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:
https://www.google.com/m8/feeds
setLabel(field)
הגדרת התווית של השדה הזה.
// Sets the label to 'Work' for the first address field associated// with contact 'John Doe'. This method can be similarly called for any// field that has a label.constcontacts=ContactsApp.getContactsByName('John Doe');constaddressFields=contacts[0].getAddresses();addressFields[0].setLabel(ContactsApp.Field.WORK_ADDRESS);
סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:
https://www.google.com/m8/feeds
setLabel(label)
הגדרת התווית של השדה הזה.
// Sets the label to 'Apartment' for the first address field associated// with contact 'John Doe'. This method can be similarly called for any// field that has a label.constcontacts=ContactsApp.getContactsByName('John Doe');constaddressFields=contacts[0].getAddresses();addressFields[0].setLabel('Apartment');
סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:
https://www.google.com/m8/feeds
שיטות שהוצאו משימוש
deleteIMField()
הוצא משימוש. הפונקציה הזו הוצאה משימוש ואין להשתמש בה בסקריפטים חדשים.
מחיקת השדה של ההודעה המיידית.
// Retrieves and deletes the AIM instant messaging field for contact 'John// Doe'constcontacts=ContactsApp.getContactsByName('John Doe');constimFields=contacts[0].getIMs(ContactsApp.Field.AIM);imFields[0].deleteIMField();
אישור
סקריפטים שמשתמשים בשיטה הזו דורשים הרשאה עם אחת או יותר מההיקפים הבאים:
[[["התוכן קל להבנה","easyToUnderstand","thumb-up"],["התוכן עזר לי לפתור בעיה","solvedMyProblem","thumb-up"],["סיבה אחרת","otherUp","thumb-up"]],[["חסרים לי מידע או פרטים","missingTheInformationINeed","thumb-down"],["התוכן מורכב מדי או עם יותר מדי שלבים","tooComplicatedTooManySteps","thumb-down"],["התוכן לא עדכני","outOfDate","thumb-down"],["בעיה בתרגום","translationIssue","thumb-down"],["בעיה בדוגמאות/בקוד","samplesCodeIssue","thumb-down"],["סיבה אחרת","otherDown","thumb-down"]],["עדכון אחרון: 2025-07-26 (שעון UTC)."],[[["\u003cp\u003e\u003cstrong\u003eDeprecated:\u003c/strong\u003e \u003ccode\u003eIMField\u003c/code\u003e is deprecated; use the People API advanced service instead.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eIMField\u003c/code\u003e represents an instant messaging field within a Contact, providing methods to get and set its address, label, and primary status.\u003c/p\u003e\n"],["\u003cp\u003eAlthough deprecated, \u003ccode\u003edeleteIMField()\u003c/code\u003e can remove an instant messaging field from a contact.\u003c/p\u003e\n"],["\u003cp\u003eSeveral methods within \u003ccode\u003eIMField\u003c/code\u003e, such as \u003ccode\u003egetAddress()\u003c/code\u003e and \u003ccode\u003esetLabel()\u003c/code\u003e, require authorization with the \u003ccode\u003ehttps://www.google.com/m8/feeds\u003c/code\u003e scope.\u003c/p\u003e\n"]]],[],null,["IMField\n\n\n**Deprecated.** Instead, use the [People API advanced\nservice](/apps-script/advanced/people)\n\nAn instant messaging field in a Contact. \n\nMethods\n\n| Method | Return type | Brief description |\n|--------------------------------------------|--------------|-----------------------------------------------|\n| [getAddress()](#getAddress()) | `String` | Get the address for this field. |\n| [getLabel()](#getLabel()) | `Object` | Gets the label for this field. |\n| [isPrimary()](#isPrimary()) | `Boolean` | Gets whether this is the primary field value. |\n| [setAddress(address)](#setAddress(String)) | [IMField](#) | Sets the address of this field. |\n| [setAsPrimary()](#setAsPrimary()) | [IMField](#) | Sets this field to primary. |\n| [setLabel(field)](#setLabel(Field)) | [IMField](#) | Sets the label of this field. |\n| [setLabel(label)](#setLabel(String)) | [IMField](#) | Sets the label of this field. |\n\nDeprecated methods\n\n| Method | Return type | Brief description |\n|-------------------------------------|-------------|---------------------------------------|\n| [deleteIMField()](#deleteIMField()) | `void` | Deletes this instant messaging field. |\n\nDetailed documentation \n\n`get``Address()` \nGet the address for this field.\n\n```javascript\n// Logs the address for the 'Home Address' field for contact 'John Doe'.\n// Can be used similarly for other fields that contain addresses.\nconst contacts = ContactsApp.getContactsByName('John Doe');\nconst homeAddress = contacts[0].getAddresses(ContactsApp.Field.HOME_ADDRESS);\nLogger.log(homeAddress[0].getAddress());\n```\n\nReturn\n\n\n`String` --- the address as a string\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.google.com/m8/feeds`\n\n*** ** * ** ***\n\n`get``Label()` \nGets the label for this field. This may be a Field, ExtendedField, or a String.\n\n```javascript\n// Logs the label for all the address fields associated with contact\n// 'John Doe'. This method can be similarly called for any field that has\n// a label.\nconst contacts = ContactsApp.getContactsByName('John Doe');\nconst addressFields = contacts[0].getAddresses();\nfor (let i = 0; i \u003c addressFields.length; i++) {\n Logger.log(addressFields[i].getLabel());\n}\n```\n\nReturn\n\n\n`Object` --- the label for this field\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.google.com/m8/feeds`\n\n*** ** * ** ***\n\n`is``Primary()` \nGets whether this is the primary field value.\n\n```javascript\n// Logs whether or not the first address field associated with contact\n// 'John Doe' is labeled as primary. This method can be similarly called\n// for any field.\nconst contacts = ContactsApp.getContactsByName('John Doe');\nconst addressFields = contacts[0].getAddresses();\nLogger.log(addressFields[0].isPrimary());\n```\n\nReturn\n\n\n`Boolean` --- whether this is primary\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.google.com/m8/feeds`\n\n*** ** * ** ***\n\n`set``Address(address)` \nSets the address of this field.\n\n```javascript\n// Sets the address for the 'Home Address' field for contact 'John Doe'.\n// Can be used similarly for other fields that contain addresses.\nconst contacts = ContactsApp.getContactsByName('John Doe');\nconst homeAddress = contacts[0].getAddresses(ContactsApp.Field.HOME_ADDRESS);\nhomeAddress[0].setAddress('123 Main St, Raleigh, NC, 27601');\n```\n\nParameters\n\n| Name | Type | Description |\n|-----------|----------|-----------------|\n| `address` | `String` | the new address |\n\nReturn\n\n\n[IMField](#) --- this field, useful for chaining\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.google.com/m8/feeds`\n\n*** ** * ** ***\n\n`set``As``Primary()` \nSets this field to primary.\n\n```javascript\n// Sets the first address field associated with contact 'John Doe'\n// as primary. This method can be similarly called for any field.\nconst contacts = ContactsApp.getContactsByName('John Doe');\nconst addressFields = contacts[0].getAddresses();\naddressFields[0].setAsPrimary();\n```\n\nReturn\n\n\n[IMField](#) --- this FieldValue for chaining\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.google.com/m8/feeds`\n\n*** ** * ** ***\n\n`set``Label(field)` \nSets the label of this field.\n\n```javascript\n// Sets the label to 'Work' for the first address field associated\n// with contact 'John Doe'. This method can be similarly called for any\n// field that has a label.\nconst contacts = ContactsApp.getContactsByName('John Doe');\nconst addressFields = contacts[0].getAddresses();\naddressFields[0].setLabel(ContactsApp.Field.WORK_ADDRESS);\n```\n\nParameters\n\n| Name | Type | Description |\n|---------|------------------------------------------------|------------------------|\n| `field` | [Field](/apps-script/reference/contacts/field) | the new standard label |\n\nReturn\n\n\n[IMField](#) --- this FieldValue for chaining\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.google.com/m8/feeds`\n\n*** ** * ** ***\n\n`set``Label(label)` \nSets the label of this field.\n\n```javascript\n// Sets the label to 'Apartment' for the first address field associated\n// with contact 'John Doe'. This method can be similarly called for any\n// field that has a label.\nconst contacts = ContactsApp.getContactsByName('John Doe');\nconst addressFields = contacts[0].getAddresses();\naddressFields[0].setLabel('Apartment');\n```\n\nParameters\n\n| Name | Type | Description |\n|---------|----------|------------------------------|\n| `label` | `String` | the new label for this field |\n\nReturn\n\n\n[IMField](#) --- this field, useful for chaining\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.google.com/m8/feeds`\n\nDeprecated methods \n\n`delete``IMField()` \n\n**Deprecated.** This function is deprecated and should not be used in new scripts.\n\nDeletes this instant messaging field.\n\n```javascript\n// Retrieves and deletes the AIM instant messaging field for contact 'John\n// Doe'\nconst contacts = ContactsApp.getContactsByName('John Doe');\nconst imFields = contacts[0].getIMs(ContactsApp.Field.AIM);\nimFields[0].deleteIMField();\n```\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.google.com/m8/feeds`"]]