Taken from the Google Apps Help document - https://support.google.com/a/answer/60218
Turn ON your Global Directory and contact sharing in your Google Apps admin console
Go to Apps > G Suite > Contacts > Settings for Contacts > Sharing Settings and select these settings:
Enable contact sharing
Show all email addresses
Show both domain profiles and Shared Contacts
Domain and public data
Just like this one...
Setup the correct timezone in the Spreadsheet, go to File > Spreadsheet Settings
and set the Locale and Timezone for your region
Set the timezone for the script, go to Tools > Script Editor
Then in the script go to File > Project Properties
Then change the Timezone to your region (it must match the spreadsheet timezone)
Click Save in the script file, go to Resources > Advanced Google Services...
And make sure the Admin Directory API - Directory_v1 is turned ON
Click OK
STOP: If you are using newer versions 1.X (displayed in the sheet name) and up then you don't need to complete the next section and go directly to User Guide - Getting Started. The next step is for older versions only. For Older versions only (1.0)
1. Get the Sheet ID by copying the ID from the URL of the Sheet (you will need this in the next part of the setup
2. In the Script choose the Code.gs file and add the following information which is located at the top of the code file
3. Add only the details highlighted in BOLD
var SPREADSHEET_ID='YOUR_SHEET_ID'; <- FROM THE PREVIOUS STEPvar DOMAIN = "yourdomain.com"; <- YOUR GOOGLE DOMAIN var SHEET_NAME = 'google'; <- THIS SHOULD BE THE SAME UNLESS YOU CHANGE THE SHEET TAB NAME var ERROR_RECIPIENT_MAIL='you@yourdomain.com'; <- YOUR EMAIL ADDRESS FOR ERROR REPORTING
4. Save and close the script file by closing the TAB
5.Go to the User Guide - Getting Started for help on using the script