Google Apps Script

Class 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();
 

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


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


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


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


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


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

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.