I am facing the following problem, when I am trying to work with an object in javascript I have troubles assigning values inside of the object. Here especially with this.sItem[i] and oInvoice.sItem[i] which are always undefined.
var oInvoice = {
sID: "",
sDate: "",
iNumberOfItems: oSpreadSheetApp.hInvoiceSheet.getRange(SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getActiveCell().getRow(), 2, 1, 1).getValues()[0],
sItem: "",
iRate: "",
iWork: "",
iCalculatedAmount: "",
sBody: "",
sComment: "",
/* Get the actual data inside range */
/* Fetch values for each row in the Range. */
mProcessInvoice: function () {
var rDataRange = oSpreadSheetApp.hInvoiceSheet.getRange(SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getActiveCell().getRow(), 1, 1, 11);
var dData = rDataRange.getValues();
var i = 0;
/* Read values */
for (i in dData) {
var rCurrentRow = dData[i]; /* Current row contains values from spreadsheet */
/* Both this.sItem[i] and oInvoice.sItem[i] are empty */
this.sItem[i] = rCurrentRow[4];
oInvoice.sItem[i] = rCurrentRow[4];
}
}
};
Logger.log(oInvoice.sItem[1]);
I am pretty sure that I am not getting a basic concept here, but gladly look forward to be enlightened.