// 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());
Renvois
String : adresse sous forme de chaîne
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation avec un ou plusieurs des champs d'application suivants:
https://www.google.com/m8/feeds
getLabel()
Récupère le libellé de ce champ. Il peut s'agir d'un champ, d'un champ étendu ou d'une chaîne.
// 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());}
Renvois
Object : libellé de ce champ
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation avec un ou plusieurs des champs d'application suivants:
https://www.google.com/m8/feeds
isPrimary()
Indique si cette valeur est la valeur du champ principal.
// 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());
Renvois
Boolean : indique si l'élément est principal
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation avec un ou plusieurs des champs d'application suivants:
https://www.google.com/m8/feeds
setAddress(address)
Définit l'adresse de ce champ.
// 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');
Les scripts qui utilisent cette méthode nécessitent une autorisation avec un ou plusieurs des champs d'application suivants:
https://www.google.com/m8/feeds
setAsPrimary()
Définit ce champ sur "principal".
// 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();
Les scripts qui utilisent cette méthode nécessitent une autorisation avec un ou plusieurs des champs d'application suivants:
https://www.google.com/m8/feeds
setLabel(field)
Définit le libellé de ce champ.
// 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);
Les scripts qui utilisent cette méthode nécessitent une autorisation avec un ou plusieurs des champs d'application suivants:
https://www.google.com/m8/feeds
setLabel(label)
Définit le libellé de ce champ.
// 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');
Les scripts qui utilisent cette méthode nécessitent une autorisation avec un ou plusieurs des champs d'application suivants:
https://www.google.com/m8/feeds
Méthodes obsolètes
deleteUrlField()
Obsolète. Cette fonction est obsolète et ne doit pas être utilisée dans les nouveaux scripts.
Supprime ce champ d'URL.
// Retrieves and deletes the Blog URL field for contact 'John// Doe'constcontacts=ContactsApp.getContactsByName('John Doe');consturlFields=contacts[0].getUrls(ContactsApp.Field.BLOG);urlFields[0].deleteUrlField();
Autorisation
Les scripts qui utilisent cette méthode nécessitent une autorisation avec un ou plusieurs des champs d'application suivants:
https://www.google.com/m8/feeds
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/07/26 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Il n'y a pas l'information dont j'ai besoin","missingTheInformationINeed","thumb-down"],["Trop compliqué/Trop d'étapes","tooComplicatedTooManySteps","thumb-down"],["Obsolète","outOfDate","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Mauvais exemple/Erreur de code","samplesCodeIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/07/26 (UTC)."],[[["\u003cp\u003e\u003ccode\u003eUrlField\u003c/code\u003e is deprecated and the People API advanced service should be used instead.\u003c/p\u003e\n"],["\u003cp\u003eIt represents a URL field within a Contact and allows you to get or set the address, label, and primary status.\u003c/p\u003e\n"],["\u003cp\u003eProvides methods to programmatically interact with a contact's URL field, such as setting the address, label, or designating it as primary.\u003c/p\u003e\n"],["\u003cp\u003eIncludes a deprecated \u003ccode\u003edeleteUrlField()\u003c/code\u003e method, which should be avoided in new scripts.\u003c/p\u003e\n"]]],[],null,["UrlField\n\n\n**Deprecated.** Instead, use the [People API advanced\nservice](/apps-script/advanced/people)\n\nA URL 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)) | [UrlField](#) | Sets the address of this field. |\n| [setAsPrimary()](#setAsPrimary()) | [UrlField](#) | Sets this field to primary. |\n| [setLabel(field)](#setLabel(Field)) | [UrlField](#) | Sets the label of this field. |\n| [setLabel(label)](#setLabel(String)) | [UrlField](#) | Sets the label of this field. |\n\nDeprecated methods\n\n| Method | Return type | Brief description |\n|---------------------------------------|-------------|-------------------------|\n| [deleteUrlField()](#deleteUrlField()) | `void` | Deletes this URL 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[UrlField](#) --- 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[UrlField](#) --- 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[UrlField](#) --- 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[UrlField](#) --- 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``Url``Field()` \n\n**Deprecated.** This function is deprecated and should not be used in new scripts.\n\nDeletes this URL field.\n\n```javascript\n// Retrieves and deletes the Blog URL field for contact 'John\n// Doe'\nconst contacts = ContactsApp.getContactsByName('John Doe');\nconst urlFields = contacts[0].getUrls(ContactsApp.Field.BLOG);\nurlFields[0].deleteUrlField();\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`"]]