1

ほとんどの連絡先に対して定義されているカスタムフィールドからカスタム値を取得しようとしていますが、以下のスクリプトからデータを取得していません。スクリプトのどこが間違っているのかを誰かが把握できます。以下は私が使用しているサンプルスクリプトです。

以下のスクリプトでは、プライマリ電子メールの値を取得できますが、連絡先に値が含まれている場合でも、すべての連絡先のカスタムフィールド値は空白です。

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) ); 
}

}

よろしく、サラバナクマールP。

4

1 に答える 1

1

これを試してください:使用

`Con_arr = All_Contacts[i].getCustomFields();`  //without the string value

とあなたのラインを交換してくださいBrowser.msgBox ...

これとともに :

if(!(Con_arr.length==0)){Logger.log(email + " **" +Con_arr[0].getLabel()+" = "+Con_arr[0].getValue() )}; 

次に、ロガーを確認します([メニュー]>[表示]>[ログ])

編集:ここに完全に簡略化されたテストコードがあります:

function GetContactDir() {

var All_Contacts = ContactsApp.getContacts();  

var email = '';
var cust = '';  
var Con_arr = new Array()

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

  email = All_Contacts[i].getPrimaryEmail();

  Con_arr = All_Contacts[i].getCustomFields() ;  
  if (!(email=="") && !(email==null) )

    if(Con_arr.length>0){Logger.log(email + " **" +Con_arr[0].getLabel()+" = "+Con_arr[0].getValue() )}; 
}
}

EDIT2:カスタムフィールドで検索して、別の方法で問題を解決してみましょう:(値を有効な値に置き換えてください)

function GetContact_test() {
var All_Contacts = ContactsApp.getContactsByCustomField('value of the field', 'name of the custom field');// note that the first term is a 'QUERY' so you don't need to give the entire ID, a single letter can bring results !
for(n=0;n<All_Contacts.length;++n){
Logger.log(n+'  '+All_Contacts[n].getFullName()); 
}
}
于 2012-06-23T15:02:28.057 に答える