I have been trying to get a custom Value from the Custom Field that is defined for most of our contacts, but we are not getting any data out of the script below, can any one figure out where I am going wrong with the script. below is the sample script I am using.
In the below script I am able to get the Primary email value, but the custom field value is blank for all the contacts even if the value is there in the contact.
function GetContactDir() {
var All_Contacts = ContactsApp.getContacts();
var email = new String();
var cust = new String();
var Con_arr = new Array();
for (var i=0; i<All_Contacts.length; i++)
{
email = "";
email = All_Contacts[i].getPrimaryEmail();
Con_arr = All_Contacts[i].getCustomFields("Organization ID"); //NOT WORKING
if (!(email=="") && !(email==null) )
Browser.msgBox(email + " **" + Con_arr[0] + " ** " + String(i) );
}
}
Regards,
Saravana Kumar P.
please try this :
use
and replace you line
Browser.msgBox ...with this :
Then look at the logger (Menu>View>log)
EDIT : here is the complete simplified test code :
EDIT2 : let’s try to take the problem the other way, searching by custom field:
(please replace values by valid ones)