Class CompanyField
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Méthodes obsolètes
deleteCompanyField()
Obsolète. Cette fonction est obsolète et ne doit pas être utilisée dans les nouveaux scripts.
Supprime ce champ d'entreprise.
// Deletes the first company associated with contact 'John Doe'
const contacts = ContactsApp.getContactsByName('John Doe');
const company = contacts[0].getCompanies()[0];
company.deleteCompanyField();
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
getCompanyName()
Obsolète. Cette fonction est obsolète et ne doit pas être utilisée dans les nouveaux scripts.
Récupère le nom de l'entreprise.
// Logs company name for all companies associated with contact 'John Doe'
const contacts = ContactsApp.getContactsByName('John Doe');
const companies = contacts[0].getCompanies();
for (const i in companies) {
Logger.log(companies[i].getCompanyName());
}
Renvois
String
: nom de l'entreprise
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
getJobTitle()
Obsolète. Cette fonction est obsolète et ne doit pas être utilisée dans les nouveaux scripts.
Récupère le titre du poste.
// Logs job title for all companies associated with contact 'John Doe'
const contacts = ContactsApp.getContactsByName('John Doe');
const companies = contacts[0].getCompanies();
for (const i in companies) {
Logger.log(companies[i].getJobTitle());
}
Renvois
String
: fonction
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()
Obsolète. Cette fonction est obsolète et ne doit pas être utilisée dans les nouveaux scripts.
Indique si cette entreprise est l'entreprise principale.
// Logs true or false depending on whether each company is the primary
// company for contact 'John Doe'
const contacts = ContactsApp.getContactsByName('John Doe');
const companies = contacts[0].getCompanies();
for (const i in companies) {
Logger.log(companies[i].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
setAsPrimary()
Obsolète. Cette fonction est obsolète et ne doit pas être utilisée dans les nouveaux scripts.
Définit cette entreprise comme entreprise principale et supprime l'entreprise précédemment définie comme telle.
// Sets the first company associated with contact 'John Doe' as primary
const contacts = ContactsApp.getContactsByName('John Doe');
const company = contacts[0].getCompanies()[0];
company.setAsPrimary();
Renvois
CompanyField
: champ "entreprise", utile pour la concaténation
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
setCompanyName(company)
Obsolète. Cette fonction est obsolète et ne doit pas être utilisée dans les nouveaux scripts.
Définit le nom de l'entreprise.
// Sets the company name for the first company associated with contact 'John
// Doe'
const contacts = ContactsApp.getContactsByName('John Doe');
const company = contacts[0].getCompanies()[0];
company.setCompanyName('ACME Corp');
Paramètres
Nom | Type | Description |
company | String | le nouveau nom de l'entreprise ; |
Renvois
CompanyField
: champ "entreprise", utile pour la concaténation
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
setJobTitle(title)
Obsolète. Cette fonction est obsolète et ne doit pas être utilisée dans les nouveaux scripts.
Définit le titre du poste.
// Sets the job title for the first company associated with contact 'John Doe'
const contacts = ContactsApp.getContactsByName('John Doe');
const company = contacts[0].getCompanies()[0];
company.setJobTitle('Manager');
Paramètres
Nom | Type | Description |
title | String | le nouveau titre du contact dans cette entreprise ; |
Renvois
CompanyField
: champ "entreprise", utile pour la concaténation
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).
[null,null,["Dernière mise à jour le 2025/07/26 (UTC)."],[[["\u003cp\u003eThe \u003ccode\u003eCompanyField\u003c/code\u003e object, representing a company field in a contact, is deprecated and should not be used in new scripts.\u003c/p\u003e\n"],["\u003cp\u003eInstead of using \u003ccode\u003eCompanyField\u003c/code\u003e, use the People API advanced service for managing contact information.\u003c/p\u003e\n"],["\u003cp\u003eAll methods associated with \u003ccode\u003eCompanyField\u003c/code\u003e, such as \u003ccode\u003edeleteCompanyField()\u003c/code\u003e, \u003ccode\u003egetCompanyName()\u003c/code\u003e, \u003ccode\u003egetJobTitle()\u003c/code\u003e, \u003ccode\u003eisPrimary()\u003c/code\u003e, \u003ccode\u003esetAsPrimary()\u003c/code\u003e, \u003ccode\u003esetCompanyName()\u003c/code\u003e, and \u003ccode\u003esetJobTitle()\u003c/code\u003e, are deprecated.\u003c/p\u003e\n"],["\u003cp\u003eScripts using these deprecated methods required authorization with the \u003ccode\u003ehttps://www.google.com/m8/feeds\u003c/code\u003e scope.\u003c/p\u003e\n"]]],["The `CompanyField` in Contacts is deprecated; the People API should be used instead. It allowed managing company details for contacts, including deleting the company field, getting the company name and job title, and determining if a company was set as primary. You could also set a company as primary, modify the company name, and change the job title associated with a specific company. All these functions are deprecated, requiring authorization with the `https://www.google.com/m8/feeds` scope.\n"],null,["# Class CompanyField\n\nCompanyField\n\n\n**Deprecated.** Instead, use the [People API advanced\nservice](/apps-script/advanced/people)\n\nCompany field in a Contact. \n\n### Deprecated methods\n\n| Method | Return type | Brief description |\n|----------------------------------------------------|-------------------|-----------------------------------------------------------------------------------------------|\n| [deleteCompanyField()](#deleteCompanyField()) | `void` | Deletes this company field. |\n| [getCompanyName()](#getCompanyName()) | `String` | Gets the company name. |\n| [getJobTitle()](#getJobTitle()) | `String` | Gets the job title. |\n| [isPrimary()](#isPrimary()) | `Boolean` | Gets whether this is the primary company. |\n| [setAsPrimary()](#setAsPrimary()) | [CompanyField](#) | Sets this company as the primary company, and unsets whatever company was previously primary. |\n| [setCompanyName(company)](#setCompanyName(String)) | [CompanyField](#) | Sets the company name. |\n| [setJobTitle(title)](#setJobTitle(String)) | [CompanyField](#) | Sets the job title. |\n\nDeprecated methods\n------------------\n\n### `delete``Company``Field()`\n\n\n**Deprecated.** This function is deprecated and should not be used in new scripts.\n\nDeletes this company field.\n\n```javascript\n// Deletes the first company associated with contact 'John Doe'\nconst contacts = ContactsApp.getContactsByName('John Doe');\nconst company = contacts[0].getCompanies()[0];\ncompany.deleteCompanyField();\n```\n\n#### Authorization\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``Company``Name()`\n\n\n**Deprecated.** This function is deprecated and should not be used in new scripts.\n\nGets the company name.\n\n```javascript\n// Logs company name for all companies associated with contact 'John Doe'\nconst contacts = ContactsApp.getContactsByName('John Doe');\nconst companies = contacts[0].getCompanies();\nfor (const i in companies) {\n Logger.log(companies[i].getCompanyName());\n}\n```\n\n#### Return\n\n\n`String` --- the name of the company\n\n#### Authorization\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``Job``Title()`\n\n\n**Deprecated.** This function is deprecated and should not be used in new scripts.\n\nGets the job title.\n\n```javascript\n// Logs job title for all companies associated with contact 'John Doe'\nconst contacts = ContactsApp.getContactsByName('John Doe');\nconst companies = contacts[0].getCompanies();\nfor (const i in companies) {\n Logger.log(companies[i].getJobTitle());\n}\n```\n\n#### Return\n\n\n`String` --- the job title\n\n#### Authorization\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()`\n\n\n**Deprecated.** This function is deprecated and should not be used in new scripts.\n\nGets whether this is the primary company.\n\n```javascript\n// Logs true or false depending on whether each company is the primary\n// company for contact 'John Doe'\nconst contacts = ContactsApp.getContactsByName('John Doe');\nconst companies = contacts[0].getCompanies();\nfor (const i in companies) {\n Logger.log(companies[i].isPrimary());\n}\n```\n\n#### Return\n\n\n`Boolean` --- whether this is primary\n\n#### Authorization\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()`\n\n\n**Deprecated.** This function is deprecated and should not be used in new scripts.\n\nSets this company as the primary company, and unsets whatever company was previously primary.\n\n```javascript\n// Sets the first company associated with contact 'John Doe' as primary\nconst contacts = ContactsApp.getContactsByName('John Doe');\nconst company = contacts[0].getCompanies()[0];\ncompany.setAsPrimary();\n```\n\n#### Return\n\n\n[CompanyField](#) --- this company field, useful for chaining\n\n#### Authorization\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``Company``Name(company)`\n\n\n**Deprecated.** This function is deprecated and should not be used in new scripts.\n\nSets the company name.\n\n```javascript\n// Sets the company name for the first company associated with contact 'John\n// Doe'\nconst contacts = ContactsApp.getContactsByName('John Doe');\nconst company = contacts[0].getCompanies()[0];\ncompany.setCompanyName('ACME Corp');\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|-----------|----------|------------------------------|\n| `company` | `String` | the new name for the company |\n\n#### Return\n\n\n[CompanyField](#) --- this company field, useful for chaining\n\n#### Authorization\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``Job``Title(title)`\n\n\n**Deprecated.** This function is deprecated and should not be used in new scripts.\n\nSets the job title.\n\n```javascript\n// Sets the job title for the first company associated with contact 'John Doe'\nconst contacts = ContactsApp.getContactsByName('John Doe');\nconst company = contacts[0].getCompanies()[0];\ncompany.setJobTitle('Manager');\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|---------|----------|---------------------------------------------------|\n| `title` | `String` | the new job title for the contact at this company |\n\n#### Return\n\n\n[CompanyField](#) --- this company field, useful for chaining\n\n#### Authorization\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`"]]