I'm attempting to create a material cut list from input entered by a user in a Google Sheets. I'm not receiving any errors except for the last part, where I try to loop over an array of objects and use the objects values to replace the text on a Google Doc. By invoking Object.value(
) the following error is thrown.
TypeError: Cannot find function value in object function Object() { [native code for Object.Object, arity=1] }.
I've tried using other object methods, but Object.value()
is the only one that allows me to get the actual values from jambObj
.
//Create jamb cut list
function jambsCutList() {
var numberOfJambCuts;
var sizeOfJambCuts;
var jambOpenings;
var jambs = 1;
var jambObj = {};
var jambArr = [];
//Loop through the first three google sheet colums
for(var i = 5; i < values.length; i++) {
numberOfJambCuts = values[i][0];
sizeOfJambCuts = values[i][1];
jambOpenings = values[i][2];
jambObj = {cuts: numberOfJambCuts, size: sizeOfJambCuts, openings:
jambOpenings};
jambArr.push(jambObj);
}
//Sort jambArr from largest cut size to smallest
jambArr.sort(function(a, b) {
return parseInt(b.size) - parseInt(a.size);
});
//Problem Code
//Loop through an array of objects and print all properties to the doc
for (var j = 0; j < jambArr.length; j++){
body.replaceText('##jambs' + jambs + '##', Object.value(jambArr[j]))
jambs += 1;
}
}