我做错了,遵循在Google数据工作室中使用Google Apps脚本开发连接器的流程之后,可以理解的是,当数据工作室在仪表板上请求字段时,该字段将进入getData并拨打电话并在请求的字段中分配数据,我正在尝试按日期字段进行过滤,当该字段被调用时,该字段将调用带有数据中断的URL,如果不存在则将调用URL而不会中断,这就是我们在讨论连接器开发流程时应该发生的情况,下面是我要创建的按字段过滤器!这就是我的意思,如果还有其他方法可以实现,那么我们将不胜感激!
var i;
for (i = 0; i < fieldName.length; i++) {
var name = fieldName[i].name;
//Logger.log(name);
if (fieldName[i].name == 'date_start' || fieldName[i].name == 'date_stop' || fieldName[i].name == 'campaign_name') {
Logger.log('Entrou no if');
url = 'https://graph.facebook.com/v3.2/'+ request.configParams.campaings_id +'/insights?fields=' + parameters + '&level=ad' + '&time_range[since]=' + dateStart + '&time_range[until]=' + dateStop + timeIncrement + limit;
} else {
url = 'https://graph.facebook.com/v3.2/'+ request.configParams.campaings_id +'/insights?fields=' + parameters;
Logger.log('Entrou no else');
}
}
var response = UrlFetchApp.fetch(url,{
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + service.getAccessToken()
}
});
var ApiMarketingWithLevel = JSON.parse(response.getContentText());
[19-03-20 14:00:32:919 BRT] Logger.log([account_currency, []]) [0 seconds]
[19-03-20 14:00:32:920 BRT] Logger.log([Entrou no else, []]) [0 seconds]
[19-03-20 14:00:32:920 BRT] Logger.log([campaign_name, []]) [0 seconds]
[19-03-20 14:00:32:921 BRT] Logger.log([Entrou no if, []]) [0 seconds]
[19-03-20 14:00:32:921 BRT] Logger.log([date_start, []]) [0 seconds]
[19-03-20 14:00:32:922 BRT] Logger.log([Entrou no if, []]) [0 seconds]
[19-03-20 14:00:32:923 BRT] Logger.log([reach, []]) [0 seconds]
[19-03-20 14:00:32:923 BRT] Logger.log([Entrou no else, []]) [0 seconds]