I am trying to get filter values in array, separated by comma in Apps Script. To illustrate, here is my function:
function filterReport(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var dataSheet = ss.getSheetByName('DATA');
var emailds = getColumnNrByName(dataSheet, 'Email');
var emailFilters = dataSheet.getRange(2, emailds, dataSheet.getLastRow() -1).getValues();
for (var i = 0; i < emailFilters.length; i++) {
var payload = JSON.stringify({
'reportMetadata': {
'reportFilters': [{
'value' : emailFilters[i][0],
'column': 'EMAIL',
'operator': 'equals'
}]
}
});
Logger.log(payload)
}
}
This is what I get:
[16-08-09 10:54:34:612 PDT] {"reportMetadata":{"reportFilters":[{"value”:”[email protected]","column":"EMAIL","operator":"equals"}]}}
[16-08-09 10:54:34:613 PDT] {"reportMetadata":{"reportFilters":[{"value":"[email protected]","column":"EMAIL","operator":"equals"}]}}
[16-08-09 10:54:34:613 PDT] {"reportMetadata":{"reportFilters":[{"value":"[email protected]","column":"EMAIL","operator":"equals"}]}}
[16-08-09 10:54:34:614 PDT] {"reportMetadata":{"reportFilters":[{"value":"[email protected]","column":"EMAIL","operator":"equals"}]}}
And I need:
{"reportMetadata":{"reportFilters":[{"value”:”[email protected], [email protected], [email protected], [email protected]","column":"EMAIL","operator":"equals"}]}}
Thanks!