Shared Contacts

Groups DirectoryEasily find out who's member of which group on your Google Apps domain.

Rating: 5 | 138,291 users

Romain Vialard & Peter Herrmann, June 2013

This Google Apps Script library provides access to the Shared Contacts of a Google Apps Domain and can only be used by accounts with administrative privileges on the domain.

It is only available to Google Apps for Business and Google Apps for Education domains.

More information: https://developers.google.com/google-apps/domain-shared-contacts/

Note: For version 33 onwards, only OAuth 2.0 is supported due to the Google deprecation of OAuth 1 on 20 April 2015. For How To use OAuth 2 with SharedContactsApp.

Note: Created shared contacts can take up to 24 hours to appear in the email address auto-complete and the contact manager.

Installing the library

  1. In the script editor, click on Resources > Manage librairies

  1. A popup box opens. Insert the following project key in the textbox: MLbRKmnCytdiSBOmoaGe1DOVJ5jnXUK_T and click on the Select button next to it.

  1. Click on the box listing the different versions of the library. Select the last version.

  1. Click OK. You can now use this library.

      1. WARNING: For now, only the methods available in the class SharedContactsApp are shown in the autocomplete.

      2. The methods of class Contact can be used but won't be shown in the autocomplete.

Base Classes

Class SharedContactsApp

Examples

function changeJobTitle() {

var contact = SharedContactsApp.getContactById('29b752309308b10');

profile.setJobTitle('Google Apps Expert');

}

function listAllContacts() {

var contacts = null;

var token = null;

do {

var result = SharedContactsApp.getContactsForPaging(token);

contacts = result.getContacts();

token = result.getToken();

for (var i = 0; i < contacts.length; i++) {

Logger.log(contacts[i].getFullName());

}

} while (token != null);

}

Class Contact

Support & Resources

Change Log

Version 33, March 2015

Version 30, November 2013

  • CreateContact now supports single quotes in the email address. e.g. Sinead O'Connor <sinead.o'connor@example.com>. Ref this SO answer.

Version 29, November 2013

  • Ampersands are now supported in the firstname and lastname when creating a contact.

Version 28, November 2013

  • The fields UrlField and AddressField are now deleted if their value is being set to an empty string.

Version 27, November 2013

  • Issue 66: CustomField.setValue() now correctly allows you to set a value after previously setting to blank.

Version 26, Aug 2013

Version 25, June 2013

First release