Overcome the issue of 'Parsing Error: Kindly verify your selector. (line XX)' in Javascript/AWQL

Hello there! Just to clarify, I am not a developer and my coding skills are limited to basic HTML. Your patience is greatly appreciated 😊

Currently, I am working with a script designed for AdWords that seems to be mainly written in Javascript. (The script is included below.)

Upon previewing the script, I encounter an error message stating 'Parsing Error: Please check your selector. (line XX)'

I have spent hours searching for a solution to this issue without any luck.

My suspicion is that the problem lies in a query returning a single or double quote, potentially causing disruptions in the code. However, I cannot confirm this theory.

Just to clarify, I have updated lines 17-21 with the correct information.

Your assistance in resolving this matter would be highly valued!

Thank you! John

/* 
// AdWords Script: Put Data From AdWords Report In Google Sheets
// --------------------------------------------------------------
// Copyright 2017 Optmyzr Inc., All Rights Reserved
// 
// This script takes a Google spreadsheet as input. Based on the column headers, data filters, and date range specified
// on this sheet, it will generate different reports.
//
// The goal is to let users create custom automatic reports with AdWords data that they can then include in an automated reporting
// tool like the one offered by Optmyzr.
//
//
// For more PPC management tools, visit www.optmyzr.com
//
*/

var DEBUG = 0; // set to 1 to get more details about what the script does while it runs; default = 0
var REPORT_SHEET_NAME = "report"; // the name of the tab where the report data should go
var SETTINGS_SHEET_NAME = "settings"; // the name of the tab where the filters and date range are specified
var SPREADSHEET_URL = "https://docs.google.com/spreadsheets/d/1dttJTb547L81XYKdTQ56LcfO9hHhbb9wm06ZY5mKhEo/edit#gid=0"; // The URL to the Google spreadsheet with your report template
var EMAIL_ADDRESSES = "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="87e2ffe6eaf7ebe2c7e2ffe6eaf7ebe2a9e4e8ea">[email protected]</a>"; // Get notified by email at this address when a new report is ready

function main() {
  var currentSetting = new Object();
  currentSetting.ss = SPREADSHEET_URL;

  // Read Settings Sheet
  var settingsSheet = SpreadsheetApp.openByUrl(currentSetting.ss).getSheetByName(SETTINGS_SHEET_NAME);
  var rows = settingsSheet.getDataRange();
  var numRows = rows.getNumRows();
  var numCols = rows.getNumColumns();
  var values = rows.getValues();
  var numSettingsRows = numRows - 1;

  var sortString = "";
  var filters = new Array();
  for(var i = 0; i < numRows; i++) {
    var row = values[i];
    var settingName = row[0];
    var settingOperator = row[1];
    var settingValue = row[2];
    var dataType = row[3];
    debug(settingName + " " + settingOperator + " " + settingValue);

    if(settingName.toLowerCase().indexOf("report type") != -1) {
      var reportType = settingValue;
    } else if(settingName.toLowerCase().indexOf("date range") != -1) {
      var dateRange = settingValue;
    } else if(settingName.toLowerCase().indexOf("sort order") != -1) {
      var sortDirection = dataType || "DESC";
      if(settingValue) var sortString = "ORDER BY " + settingValue + " " + sortDirection;
      var sortColumnIndex = 1;
    }else {
      if(settingOperator && settingValue) {
        if(dataType.toLowerCase().indexOf("long") != -1 || dataType.toLowerCase().indexOf("double") != -1 || dataType.toLowerCase().indexOf("money") != -1 || dataType.toLowerCase().indexOf("integer") != -1) {
          var filter =  settingName + " " + settingOperator + " " + settingValue;
        } else {
          if(settingValue.indexOf("'") != -1) {
            var filter =  settingName + " " + settingOperator + ' "' + settingValue + '"';
          } else if(settingValue.indexOf("'") != -1) {
            var filter =  settingName + " " + settingOperator + " '" + settingValue + "'";
          } else {
            var filter =  settingName + " " + settingOperator + " '" + settingValue + "'";
          }
        }
        debug("filter: " + filter)
        filters.push(filter);
      }
    }
  }


  // Process the report sheet and fill in the data
  var reportSheet = SpreadsheetApp.openByUrl(currentSetting.ss).getSheetByName(REPORT_SHEET_NAME);
  var rows = reportSheet.getDataRange();
  var numRows = rows.getNumRows();
  var numCols = rows.getNumColumns();
  var values = rows.getValues();
  var numSettingsRows = numRows - 1;

  // Read Header Row and match names to settings
  var headerNames = new Array();
  var row = values[0];
  for(var i = 0; i < numCols; i++) {
    var value = row[i];
    headerNames.push(value);
    //debug(value);
  } 



  if(reportType.toLowerCase().indexOf("performance") != -1) {
    var dateString = ' DURING ' + dateRange;
  } else {
    var dateString = "";
  }
  if(filters.length) {
    var query = 'SELECT ' + headerNames.join(",") + ' FROM ' + reportType + ' WHERE ' + filters.join(" AND ") + dateString + " " + sortString;
  } else {
    var query = 'SELECT ' + headerNames.join(",") + ' FROM ' + reportType + dateString + " " + sortString;
  }
  debug(query);
  var report = AdWordsApp.report(query); //THIS IS LINE 103 WITH THE ERROR
  try {
    report.exportToSheet(reportSheet);
    var subject = "Your " + reportType + " for " + dateRange + " for " + AdWordsApp.currentAccount().getName() + " is ready";
    var body = "currentSetting.ss<br>You can now add this data to <a href='https://www.optmyzr.com'>Optmyzr</a> or another reporting system.";
    MailApp.sendEmail(EMAIL_ADDRESSES, subject, body);
    Logger.log("Your report is ready at " + currentSetting.ss);
    Logger.log("You can include this in your scheduled Optmyzr reports or another reporting tool.");
  } catch (e) {
    debug("error: " + e);
  }

}

function debug(text) {
  if(DEBUG) Logger.log(text);
}

Answer â„–1

If you notice, the selector is the area between the SELECT and FROM statements in the query. It seems that no fields are being selected due to an empty headerNames array. Be sure to double check the value stored in REPORT_SHEET_NAME.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for retrieving values from numerous checkboxes sharing the same class using jQuery

Currently, I am struggling with getting the values of all checkboxes that are checked using jquery. My goal is to store these values in an array, but I am encountering difficulties. Can anyone provide me with guidance on how to achieve this? Below is what ...

Tips for troubleshooting my website?

After making some updates to my website, I noticed that an ajax script is no longer functioning properly. Since I hired someone else to write the code, I'm not sure how to troubleshoot it. Initially, this is what it should look like: When you select ...

Filtering JSON data with JavaScript

Looking to group data in AngularJS using UnderscoreJS. Here is the JSON data: data = [ { "Building*": "Building A", "Wing*": "Wing C", "Floor*": "Floor 3", "Room Name*": "Room 3", "Room Type*": ...

Adjusting the range input alters color progressively

I am trying to create a range input with a dynamic background color that changes as the slider is moved. Currently, the background is blue but I want it to start as red and transition to yellow and then green as the slider moves to the right. Does anyone ...

How can you use JavaScript to create hyperlinks for every occurrence of $WORD in a text without altering the original content?

I've hit a bit of a roadblock. I'm currently working with StockTwits data and their API requires linking 'cashtags' (similar to hashtags but using $ instead of #). The input data I have is This is my amazing message with a stock $sym ...

make the chosen text appear on Internet Explorer

1 How to insert text into a text box using code? 2 Moving the caret to the end of the text. 3 Ensuring the caret is visible by scrolling the text box content. 4 Programmatically selecting specific text in a textbox. 5 **How to make selected text visible?** ...

The issue is that only the first checkbox within ngFor is being toggled on and off each time a different checkbox is clicked

When I have checkboxes inside a ngFor loop and click on any one of them, only the first one gets checked and unchecked, updating only the status of the first checkbox. Here is the HTML template: <div *ngFor="let num of count" class="m-b-20"> & ...

Is it possible to have two unique keys in a single MongoDB schema?

Currently attempting to achieve this functionality using mongoose: const newContent = new Schema({ heading: { type: String, unique: true }, url: { type: String, unique: true }, //... }); However, an error is being thrown: MongoError: E11000 dupl ...

Contrasting the variance between binding through the [] syntax and abstaining

There is a unique custom my-table element that has its row property bound to the host component. There are two different ways in which HTML can be inserted: <my-table [rows]="displayEntriesCount"></my-table> and alternatively: <my-table r ...

Unravel the ReadableStream object in nextjs 13 api route

I am encountering an issue with my server-side code where a value I am sending is not being interpreted correctly. My project is utilizing the experimental App directory feature of NextJS. //src/app/api/auth/route.js export async function POST(req, res) { ...

Finding the dynamic width of a div using JavaScript

I have two divs named demo1 and demo2. I want the width of demo2 to automatically adjust when I drag demo1 left to right or right to left. <div class="wrapper"> <div class="demo"></div> <div class="demo2"&g ...

Clear previously filtered items

I am currently working on implementing a search functionality using Javascript for my project, but I've hit a snag. After hiding certain items, I'm having trouble making them appear again. JSFiddle The code I have so far is as follows: $(' ...

Enhancing d3 pie chart with additional information when hovering over slices

I'm currently working on finding a way to display additional text on a pie chart using mouseover in addition to just the data bound to the pie. Here is the code I have implemented: function Pie(value,names){ svg.selectAll("g.arc").remove() var oute ...

AngularJS JSON Array

I have an array containing multiple objects in JSON, as well as a select element that contains an array. Depending on the selection made in the first array, another select box will be dynamically loaded right below it. HTML Code <div class="list"> ...

Chart.js encounters difficulties displaying the chart due to the data in reactjs

My goal is to utilize chartjs-2 to showcase a bar graph with data. Below is the code I've implemented: import React from "react"; import { Bar, Line, Pie } from "react-chartjs-2"; export default class App extends React.Component { constructor(pro ...

Discovering the data-id value in an HTML element by clicking it with JavaScript and returning that value through a for loop

this is my unique html content <ul class="dialogs"> {% if t_dialogs %} <li class="grouping">Today</li> {% for item in t_dialogs %} <li class=&qu ...

Leveraging JavaScript to determine whether a number is even or exiting by pressing the letter "q"

The main goal is to have the user input a number to check if it is even, or enter 'q' to exit the program. var readlineSync = require('readline-sync'); var i = 0; while (i <= 3) { var num = readlineSync.question ...

Can someone please help me figure out why the "setInterval" function in my script isn't functioning as expected?

I've been experimenting with controlling the refresh rate of drawn objects in a canvas using JavaScript. Even after going through the tutorials and examples on w3.school, I'm still unsure why the "setInterval" function is not executing the "gener ...

How does an iOS device typically manage the :hover pseudo-class?

My div is designed to expand when clicked using jQuery $('.mydiv').click, and collapse with a second click. In addition, the same div showcases more information on hover due to CSS rules utilizing :hover. This feature works perfectly on a comput ...

How to import a module from the root path using TypeScript in IntelliJ IDEA

Despite this topic being widely discussed, I still struggle to understand it. Below is my tsconfig.json file: { "compilerOptions": { "module": "commonjs", "target": "es2017", "sourceMap": true, "declaration": true, "allowSyntheticDe ...