Stay organized with collections
Save and categorize content based on your preferences.
AI-generated Key Takeaways
The CompanyField object, representing a company field in a contact, is deprecated and should not be used in new scripts.
Instead of using CompanyField, use the People API advanced service for managing contact information.
All methods associated with CompanyField, such as deleteCompanyField(), getCompanyName(), getJobTitle(), isPrimary(), setAsPrimary(), setCompanyName(), and setJobTitle(), are deprecated.
Scripts using these deprecated methods required authorization with the https://www.google.com/m8/feeds scope.
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'constcontacts=ContactsApp.getContactsByName('John Doe');constcompany=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()
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'constcontacts=ContactsApp.getContactsByName('John Doe');constcompanies=contacts[0].getCompanies();for(constiincompanies){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()
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'constcontacts=ContactsApp.getContactsByName('John Doe');constcompanies=contacts[0].getCompanies();for(constiincompanies){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()
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'constcontacts=ContactsApp.getContactsByName('John Doe');constcompanies=contacts[0].getCompanies();for(constiincompanies){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()
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 primaryconstcontacts=ContactsApp.getContactsByName('John Doe');constcompany=contacts[0].getCompanies()[0];company.setAsPrimary();
Return
CompanyField — this company field, useful for chaining
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.google.com/m8/feeds
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'constcontacts=ContactsApp.getContactsByName('John Doe');constcompany=contacts[0].getCompanies()[0];company.setCompanyName('ACME Corp');
Parameters
Name
Type
Description
company
String
the new name for the company
Return
CompanyField — this company field, useful for chaining
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
https://www.google.com/m8/feeds
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'constcontacts=ContactsApp.getContactsByName('John Doe');constcompany=contacts[0].getCompanies()[0];company.setJobTitle('Manager');
Parameters
Name
Type
Description
title
String
the new job title for the contact at this company
Return
CompanyField — this company field, useful for chaining
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-12-02 UTC."],[],["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"]]