I generally program in VBA, but my company is moving towards google docs to replace Excel. My question stems around Object and Collections. In VBA, I am able to create a Class Module and create an object. It looks like I can't do that in Apps Script. Further, in VBA, I simply declare a collection inside of a sub like dim Col as new collection. However, I can't seem to get that right in my Apps Script. Below is my current code. I am trying to loop through line items, saving the line items as an object and storing that object in a collection with a key. Any help would be great! Right now when I compile the below code, it says the collection() is undefined.
function Create_Collection(){
var DFws = SpreadsheetApp.getActive().getSheetByName('Data Feed')
var KPws = SpreadsheetApp.getActive().getSheetByName('KP')
var DF_lastrow
var KP_lastrow
var CycleDate
var DF_Date
var i
var Ingcol = new Collection();
CycleDate = KPws.getRange(1,2).getValue(); //Sets which cycle ingredients need to be collected
DF_lastrow = DFws.getLastRow();
for (i = 2; i<= DF_lastrow; i++){
DF_Date = DFws.getRange(i,1).getValue();
if(DF_Date.toString() == CycleDate){
var IngObj = { } // empty object
IngObj.KitchenID = DFws.getRange(i,22).getValue(); // Added property KitchenID
IngObj.Recipe = DFws.getRange(i,3).getValue(); // Added property Recipe
IngObj.Name = DFws.getRange(i,4).getValue(); // Added property Name
Ingcol.add (IngObj.KitchenID,IngObj)
}
}