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
In the script editor, click on Resources > Manage librairies
A popup box opens. Insert the following project key in the textbox: MLbRKmnCytdiSBOmoaGe1DOVJ5jnXUK_T and click on the Select button next to it.
Click on the box listing the different versions of the library. Select the last version.
Click OK. You can now use this library.
WARNING: For now, only the methods available in the class SharedContactsApp are shown in the autocomplete.
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
The SharedContactsApp library was created by Romain Vialard and Peter Herrmann.
You can view the source code here.
Discuss in the Google Apps Script Community on Google+.
Ask questions on Stack Overflow using the tag google-apps-script.
Change Log
Version 33, March 2015
OAuth 2.0 (only) support due to deprecation of OAuth 1 on 20 April 2015. For How To see OAuth 2 with SharedContactsApp.
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
Reauthorised ProfilesApp to use Session.getEffectiveUser() as per Google documentation alert here https://developers.google.com/apps-script/scripts_google_accounts#reauth today. If you have a script that you've upgraded to use the new authorization experience and your script includes SharedContactsApp, then you need to follow those same instructions.
Version 25, June 2013
First release