Class CompanyField

CompanyField

Company field in a Contact.

Methods

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.

Detailed documentation

deleteCompanyField()

Deletes this company field.

// Deletes the first company associated with contact 'John Doe'
var contacts = ContactsApp.getContactsByName('John Doe');
var 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()

Gets the company name.

// Logs company name for all companies associated with contact 'John Doe'
var contacts = ContactsApp.getContactsByName('John Doe');
var companies = contacts[0].getCompanies();
for (var 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()

Gets the job title.

// Logs job title for all companies associated with contact 'John Doe'
var contacts = ContactsApp.getContactsByName('John Doe');
var companies = contacts[0].getCompanies();
for (var 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()

Gets whether this is the primary company.

// Logs true or false depending on whether each company is the primary
// company for contact 'John Doe'
var contacts = ContactsApp.getContactsByName('John Doe');
var companies = contacts[0].getCompanies();
for (var 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()

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
var contacts = ContactsApp.getContactsByName('John Doe');
var 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

setCompanyName(company)

Sets the company name.

// Sets the company name for the first company associated with contact 'John Doe'
var contacts = ContactsApp.getContactsByName('John Doe');
var 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

setJobTitle(title)

Sets the job title.

// Sets the job title for the first company associated with contact 'John Doe'
var contacts = ContactsApp.getContactsByName('John Doe');
var 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

发送以下问题的反馈:

此网页
Apps Script
Apps Script
需要帮助?请访问我们的支持页面