var ss = SpreadsheetApp.openByUrl(url) var sheet = ss.getSheetByName(sheet); var data = sheet.getDataRange().getValues(); var negativeKeywords = data.filter(String) var listIter = AdsApp.negativeKeywordLists() .withCondition('Name = "' + listName + '"') .get(); while (listIter.hasNext()) { var list = listIter.next();
// Here I would like to clear the list
for (i=0;i<negativeKeywords.length;i++) { list.addNegativeKeywords(negativeKeywords[i]) } }
var ss = SpreadsheetApp.openByUrl(url) var sheet = ss.getSheetByName(sheet); var data = sheet.getDataRange().getValues(); var negativeKeywords = data.filter(String) var listIter = AdsApp.negativeKeywordLists() .withCondition('Name = "' + listName + '"') .get();
if (listIter.totalNumEntities() == 1) { var list = listIter.next(); var existingKeywordsIter = list.negativeKeywords().get(); var existingKeywords = []; while (existingKeywordsIter.hasNext()) { existingKeywords.push(existingKeywordsIter.next()); } for (a=0;a<existingKeywords.length;a++) { existingKeywords[a].remove(); } for (b=0;b<negativeKeywords.length;b++) { list.addNegativeKeywords(negativeKeywords[b]) } }