javascript - Invalid assignment left-hand side. (line 1) -
i'm making adwords script (it uses javascript) , gives me error: "invalid assignment left-hand side. (line 1)"
. can't find error. please help? thanks
function main() { var todaydate = getdatestring(new date(),'h'); logger.log('son las '+todaydate+' horas'); if (todaydate = 11) { var spreadsheet = spreadsheetapp.create("cpc log "+getdatestring(new date(), 'dd-mm-yy')); var sheet = spreadsheet.getactivesheet(); var report = adwordsapp.report("select campaignname, adgroupname, keywordmaxcpc adgroup_performance_report during today"); report.exporttosheet(sheet); var expectedratio = 30; var cpcmultiplier = 1.2; cpcmodifier(expectedratio,sheet,cpcmultiplier); } }
i add complete code, if needs take @ it:
function main() { var todaydate = getdatestring(new date(), 'h'); logger.log('son las ' + todaydate + ' horas'); if (todaydate == 11) { var spreadsheet = spreadsheetapp.create("cpc log " + getdatestring(new date(), 'dd-mm-yy')); var sheet = spreadsheet.getactivesheet(); var report = adwordsapp.report("select campaignname, adgroupname, keywordmaxcpc adgroup_performance_report during today"); report.exporttosheet(sheet); var expectedratio = 30; var cpcmultiplier = 1.2; cpcmodifier(expectedratio, sheet, cpcmultiplier); } } function getdatestring(date, format) { return utilities.formatdate(new date(date), adwordsapp.currentaccount().gettimezone(), format); } function cpcmodifier(ratio, sheet, cpcmultiplier) { var campaigniterator = adwordsapp.campaigns().withcondition("status = paused").get(); while (campaigniterator.hasnext()) { var campaign = campaigniterator.next(); var campaignname = campaign.getname(); var campaignbudget = campaign.getbudget(); var campaignspent = campaign.getstatsfor("today").getcost(); var campaignspentratio = (campaignspent / campaignbudget) * 100; logger.log("la campaña " + campaignname + " lleva gastados $" + campaignspent + " sobre un presupuesto de $" + campaignbudget + ". esto representa el " + campaignspentratio + "%."); if (campaignspentratio < ratio) { var adgroupiterator = adwordsapp.adgroups().withcondition("status = enabled").withcondition("campaignname = '" + campaignname + "'").get(); while (adgroupiterator.hasnext()) { var adgroup = adgroupiterator.next(); var adgroupname = adgroup.getname(); (var row = 2; row > 1; row++) { var cname = sheet.getrange("a" + row).getvalue(); var agname = sheet.getrange("b" + row).getvalue(); if (cname == '') break; if (cname == campaignname && agname = adgroupname) { var agmaxcpc = sheet.getrange("c" + row).getvalue(); if (agmaxcpc == '--') { logger.log("el grupo de anuncios " + adgroupname + "(campaña " + campaignname + ") no tiene cpc definido. no se aplicarán modificaciones."); break; } else { var agnewcpc = agmaxcpc * cpcmultiplier; logger.log("el cpc máximo predeterminado del grupo de anuncios " + adgroupname + "(campaña " + campaignname + ") es de " + agmaxcpc + ". cambiándolo " + agnewcpc); break; } } } adgroup.setkeywordmaxcpc(agnewcpc); } } } }
solved:
i found this:
if (cname == campaignname && agname **=** adgroupname) {
and should be:
if (cname == campaignname && agname == adgroupname) {
typo:
replace:
if (todaydate = 11) { // that's assignment
with:
if (todaydate == 11) { // that's "equals" operator
Comments
Post a Comment