google / dv360-api

Apache License 2.0
34 stars 10 forks source link

Error when the workbook has multiple sheets #14

Open Zweitze opened 2 years ago

Zweitze commented 2 years ago

A colleague came to me because this script was giving errors. He deployed the solution, but he ended up with multiple sheets - I have no idea how he managed that. Funny enough, menu function "Only check weather" works as advertised. But running "Check weather and sync DV360" gives this error in the log:

TypeError: Cannot read property '0' of undefined
    at forceFormulasEval(Code:505:59)
    at main(Code:1712:41)
    at monitorWeatherAndSyncWithDV360(Code:1762:12)

The problem: function forceFormulasEval assumes the default sheet to be the Triggers sheet. Applying the following change will fix the problem:

  forceFormulasEval(row, col) {
    //return this.get(`R${row}C${col}`, 'UNFORMATTED_VALUE')[0][0];
    return this.get(`${configSpreadsheetName}!R${row}C${col}`, 'UNFORMATTED_VALUE')[0][0];
  }
otago-gd commented 2 years ago

Thanks a lot! Solved the problem for me!