AI-generated Key Takeaways
-
The
CompanyFieldfunctionality is deprecated and should not be used in new scripts. -
The People API advanced service is recommended as a replacement for
CompanyField. -
Deprecated methods for
CompanyFieldinclude deleting, getting, and setting company name and job title, as well as managing the primary company.
Deprecated methods
| Method | Return type | Brief description |
|---|---|---|
| void | Deletes this company field. |
| String | Gets the company name. |
| String | Gets the job title. |
| Boolean | Gets whether this is the primary company. |
| | Sets this company as the primary company, and unsets whatever company was previously primary. |
| | Sets the company name. |
| | Sets the job title. |
Deprecated methods
deleteCompanyField()
deleteCompanyField() Deprecated. This function is deprecated and should not be used in new scripts.
Deletes this company field.
// Deletes the first company associated with contact 'John Doe' const contacts = ContactsApp.getContactsByName('John Doe'); const company = contacts[0].getCompanies()[0]; company.deleteCompanyField();
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
getCompanyName()
getCompanyName() Deprecated. This function is deprecated and should not be used in new scripts.
Gets the company name.
// 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()); }
Return
String — the name of the company
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
getJobTitle()
getJobTitle() Deprecated. This function is deprecated and should not be used in new scripts.
Gets the job title.
// 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()); }
Return
String — the job title
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
isPrimary()
isPrimary() Deprecated. This function is deprecated and should not be used in new scripts.
Gets whether this is the primary company.
// 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()); }
Return
Boolean — whether this is primary
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
setAsPrimary()
setAsPrimary() Deprecated. This function is deprecated and should not be used in new scripts.
Sets this company as the primary company, and unsets whatever company was previously primary.
// 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();
Return
— this company field, useful for chainingCompany
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
setCompanyName(company)
setCompanyName(company) Deprecated. This function is deprecated and should not be used in new scripts.
Sets the company name.
// 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');
Parameters
| Name | Type | Description |
|---|---|---|
company | String | the new name for the company |
Return
— this company field, useful for chainingCompany
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds
setJobTitle(title)
setJobTitle(title) Deprecated. This function is deprecated and should not be used in new scripts.
Sets the job title.
// 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');
Parameters
| Name | Type | Description |
|---|---|---|
title | String | the new job title for the contact at this company |
Return
— this company field, useful for chainingCompany
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.google.com/m8/feeds