I am trying to convert calendar dates to fiscal dates. I've been successfully able to do all that. My problem is trying to write the fiscal date values back into the spreadsheet. Here is the code:
var dates = [];
var fyear = [];
var fiscalDates = [];
for (var x=1; x < getLastRows;x++) {
dates[x] = getFiscalValues[x][9];
fyear[x] = getFiscalValues[x][37];
fiscalDates[x] = [];
if (fyear[x] == "") {
var fiscalRowNumber = fiscalUpdate(dates[x]);
var openFiscalSS = SpreadsheetApp.openById(fiscalRowNumber[0]);
var openFiscalYear = openFiscalSS.getSheetByName(fiscalRowNumber[2]);
var fiscalCols = openFiscalYear.getDataRange().getLastColumn();
var fiscalValues = openFiscalYear.getRange(fiscalRowNumber[1],1,1,fiscalCols).getValues();
// this array now contains all the values required for the current fiscal
fiscalDates[x][0] = fiscalRowNumber[2];
fiscalDates[x][1] = fiscalValues[0][0];
fiscalDates[x][2] = fiscalValues[0][1];
fiscalDates[x][3] = fiscalValues[0][2];
fiscalDates[x][4] = fiscalValues[0][3];
} // end of if statement that checks if Fiscal year is blank
} // end of the for loop that updates the fiscal dates for each row
var openTM = SpreadsheetApp.openById(tmFileString);
var openTmResponse = openTM.getSheetByName(tmResponses);
openTmResponse.getRange(2,40,getLastRows,5).setValues([fiscalDates]);
The error I am getting when I attempt to write back the values to the spreadsheet is "Incorrect range height, was 1 but should be 132". I checked the values of getLastRows and the length of fiscalDates array - both numbers are the same.
I can't seem to figure out what I am doing wrong with the last statement.
Logger.log(fiscalDates)
before the last line, to see what's in your array.