InputError: Mapping for ManagedCustomerService.ManagerCustomerId not available.

272 views
Skip to first unread message

渡邉雄一郎

unread,
Aug 29, 2022, 10:38:51 AM8/29/22
to Google Ads Scripts Forum
hello,
Sorry for the elementary problem.

 "The new scripting experience ”, an error occurs when the following script is executed. 


-----
//レポート出力対象CustomerID ★変更してください★
var MANAGER_CUSTOMER_ID = '6044700537';
 
//出力先スプレッドシートのURL ★変更してください★
var SPREADSHEET_URL = 'https://docs.google.com/spreadsheets/d/1AMZdOdreiJZRGMFAg4Kvy3PrNkrBaZMks024COYe30I/edit';
 
//出力スプレッド行
var row = 1;
 
function main() {
  //------------------------
  // スプレッドシートを用意
  //------------------------
  //スプレッドシートを展開
  var spreadSheet = SpreadsheetApp.openByUrl(SPREADSHEET_URL);
  //出力先シートを宣言
  var sheet = spreadSheet.getSheetByName('Google(当月)自動更新テスト');
  //タイトルを表示
  setTitle(sheet);
 
  //----------------------------------------------
  // Google広告データを取得・スプレッドシートに出力
  //----------------------------------------------
  createReport(function(account) {
    //メインデータ取得
    var mainData = getMainData();
    viewAllData(mainData, sheet);
  });
}
 
/**
 * アカウント情報取得
 * @param {*} callback
 */
function createReport(callback) {
 
  //MCCidを指定してアカウント情報を取得
  var accountIterator = AdsManagerApp.accounts()
                              .withCondition("ManagerCustomerId = '"+MANAGER_CUSTOMER_ID+"'")
                              .get();
  Logger.log('アカウント件数 : ' + accountIterator.totalNumEntities());
 
  //アカウント単位でデータ抽出
  while(accountIterator.hasNext()) {
 
    var account = accountIterator.next();
 
    //MCC内に存在する対象のアカウント情報を取得
    AdsManagerApp.select(account);
 
    //main()内にて宣言したfunctionを実行する
    callback(account);
  }
}
 
/**
 * タイトル表示
 * @param {object} sheet スプレッドシートオブジェクト
 */
function setTitle(sheet){
  sheet.getRange(row, 1).setValue('アカウントID');
  sheet.getRange(row, 2).setValue('アカウント名');
  sheet.getRange(row, 3).setValue('表示回数');
  sheet.getRange(row, 4).setValue('クリック数');
  sheet.getRange(row, 5).setValue('コンバージョン数');
  sheet.getRange(row, 6).setValue('費用');
  row++;
}
 
/**
 * メインデータ取得
 */
function getMainData() {

/*
var today = new Date();
const fromdate = Utilities.formatDate(new Date(today.getFullYear(), today.getMonth() , 1), 'Asia/Tokyo', 'yyyyMMdd');
    Logger.log('From:'+fromdate);
const todate = Utilities.formatDate(new Date(today.getFullYear(), today.getMonth(), today.getDate() ), 'Asia/Tokyo', 'yyyyMMdd');
    Logger.log('To:'+todate);
*/
 
  var data = [];
  var rows = AdsApp.report(
    'SELECT ExternalCustomerId, CustomerDescriptiveName, Clicks, Impressions, Cost, Conversions'
    + ' FROM ACCOUNT_PERFORMANCE_REPORT '
    + ' DURING THIS_MONTH'
//    + ' DURING   + fromdate + , + todate + '
//    + ' DURING  20220801,20220825'
  ).rows();
 
  while (rows.hasNext()) {
    var row = rows.next();
    try {
      data['ExternalCustomerId'] = row['ExternalCustomerId'];
      data['CustomerDescriptiveName'] = row['CustomerDescriptiveName'];
      data['Clicks'] = row['Clicks'];
      data['Impressions'] = row['Impressions'];
      data['Conversions'] = row['Conversions'];      
      data['Cost'] = row['Cost'];      
    } catch (ex) {
      Logger.log('Exception:'+ex);
    }
  }
  return data;
}
 

/**
 * スプレッドシートにデータ出力
 * @param {array} mainData メインデータ
 * @param {array} cvData CVデータ
 * @param {object} sheet スプレッドシートオブジェクト
 */
function viewAllData(mainData, sheet){
  //メインデータがundefinedの場合
  if(mainData['ExternalCustomerId'] === void 0) return;
  sheet.getRange(row, 1).setValue(mainData['ExternalCustomerId']);
  sheet.getRange(row, 2).setValue(mainData['CustomerDescriptiveName']);
  sheet.getRange(row, 3).setValue(mainData['Impressions']);
  sheet.getRange(row, 4).setValue(mainData['Clicks']);
  sheet.getRange(row, 5).setValue(mainData['Conversions']);
  sheet.getRange(row, 6).setValue(mainData['Cost']);

  row++;
}
-----



 The log is output as follows. 

-----
 "2022/8/29 15:39:32 InputError: Mapping for ManagedCustomerService.ManagerCustomerId not available. at Object.Fh (adsmanagerapp_compiled:2613:11) atc (adsmanagerapp_compiled:2305:27) at nh.Fa (adsmanagerapp_compiled:2320:23) at nh.withCondition (adsmanagerapp_compiled:585:17) at Hh.withCondition (adsmanagerapp_compiled:2435:14) ”
-----

error.png

Google Ads Scripts Forum

unread,
Sep 16, 2022, 3:25:34 AM9/16/22
to Google Ads Scripts Forum
Reposting the last inquiry (https://groups.google.com/g/adwords-scripts/c/99Xt7QhNGN4) from the forum as it wasn't routed to our support queue.

Regards,
Yasmin
Google Ads Scripts Team

Google Ads Scripts Forum Advisor

unread,
Sep 16, 2022, 3:01:45 PM9/16/22
to adwords...@googlegroups.com
Hello,

Thanks for reaching out. Can you please reply privately with your CID and script name so that we can check the script in your account?

Thanks,

Google Logo
Matt
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2ePEdg:ref

渡邉雄一郎

unread,
Oct 1, 2022, 4:25:02 PM10/1/22
to Google Ads Scripts Forum
Hi

CID and script name.

SCRIPT NAME:Get_All_Report_EMnet_V3_DAY

2022年9月17日土曜日 4:01:45 UTC+9 adsscripts:

Google Ads Scripts Forum Advisor

unread,
Oct 3, 2022, 1:33:31 AM10/3/22
to adwords...@googlegroups.com

Hello,

I’m James from the Google Ads scripts support team. Thank you for contacting us.

You mentioned that when executing your script to the new script experience version, your script encountered an error. Upon checking, I observed that you have migrated the codes in your script in the new script experience setup which is the main reason why it is not working properly on your end. Take note that enabling or toggling on the new script experience button within your script editor will not automatically convert or migrate your existing script. However, as we have mentioned in our blog post, you should manually move your scripts over to the new experience before then to ensure continued functionality. Please be informed that the new script experience is now based on Google Ads API infrastructure.

That said, I would suggest that you refer to the following links below on how you can migrate your script to the new script experience version.

Regards,

Google Logo
James Howell
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2ePEdg:ref
Reply all
Reply to author
Forward
0 new messages