Class CompanyField

CompanyField

Deprecated. Instead, use the People API advanced service

Company field in a Contact.

MethodReturn typeBrief description
deleteCompanyField()voidDeletes this company field.
getCompanyName()StringGets the company name.
getJobTitle()StringGets the job title.
isPrimary()BooleanGets whether this is the primary company.
setAsPrimary()CompanyFieldSets this company as the primary company, and unsets whatever company was previously primary.
setCompanyName(company)CompanyFieldSets the company name.
setJobTitle(title)CompanyFieldSets the job title.

Deprecated methods

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

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

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

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

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

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

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

NameTypeDescription
companyStringthe 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

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

NameTypeDescription
titleStringthe 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:

  • https://www.google.com/m8/feeds