Get all object properties from an array of objects
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
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;
}
}
object google-apps-script
add a comment |
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;
}
}
object google-apps-script
Object.value? Link documentation on such method.
– TheMaster
Nov 16 '18 at 22:35
1
Unfortunately,Object.values()
cannot be used at Google Apps Script yet. So how about usingObject.keys(jambArr[j]).map(function(e){return jambArr[j][e]})
instead ofObject.value(jambArr[j])
? But I'm not sure whether the result of modifiedbody.replaceText()
is what you want. If the result was not what you want, can you provide the detail information about the result you want?
– Tanaike
Nov 16 '18 at 22:37
1
Yes,Object.values()
does not work because Google Apps Scripts roughly supports ES5 JavaScript, and this feature was not introduced until later. See: Which Edition of ECMA-262 Does Google Apps Script Support?
– Dustin Michels
Nov 16 '18 at 23:10
add a comment |
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;
}
}
object google-apps-script
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;
}
}
object google-apps-script
object google-apps-script
edited Feb 20 at 20:55
pnuts
49.3k764101
49.3k764101
asked Nov 16 '18 at 22:01
AndyHarbinAndyHarbin
1
1
Object.value? Link documentation on such method.
– TheMaster
Nov 16 '18 at 22:35
1
Unfortunately,Object.values()
cannot be used at Google Apps Script yet. So how about usingObject.keys(jambArr[j]).map(function(e){return jambArr[j][e]})
instead ofObject.value(jambArr[j])
? But I'm not sure whether the result of modifiedbody.replaceText()
is what you want. If the result was not what you want, can you provide the detail information about the result you want?
– Tanaike
Nov 16 '18 at 22:37
1
Yes,Object.values()
does not work because Google Apps Scripts roughly supports ES5 JavaScript, and this feature was not introduced until later. See: Which Edition of ECMA-262 Does Google Apps Script Support?
– Dustin Michels
Nov 16 '18 at 23:10
add a comment |
Object.value? Link documentation on such method.
– TheMaster
Nov 16 '18 at 22:35
1
Unfortunately,Object.values()
cannot be used at Google Apps Script yet. So how about usingObject.keys(jambArr[j]).map(function(e){return jambArr[j][e]})
instead ofObject.value(jambArr[j])
? But I'm not sure whether the result of modifiedbody.replaceText()
is what you want. If the result was not what you want, can you provide the detail information about the result you want?
– Tanaike
Nov 16 '18 at 22:37
1
Yes,Object.values()
does not work because Google Apps Scripts roughly supports ES5 JavaScript, and this feature was not introduced until later. See: Which Edition of ECMA-262 Does Google Apps Script Support?
– Dustin Michels
Nov 16 '18 at 23:10
Object.value? Link documentation on such method.
– TheMaster
Nov 16 '18 at 22:35
Object.value? Link documentation on such method.
– TheMaster
Nov 16 '18 at 22:35
1
1
Unfortunately,
Object.values()
cannot be used at Google Apps Script yet. So how about using Object.keys(jambArr[j]).map(function(e){return jambArr[j][e]})
instead of Object.value(jambArr[j])
? But I'm not sure whether the result of modified body.replaceText()
is what you want. If the result was not what you want, can you provide the detail information about the result you want?– Tanaike
Nov 16 '18 at 22:37
Unfortunately,
Object.values()
cannot be used at Google Apps Script yet. So how about using Object.keys(jambArr[j]).map(function(e){return jambArr[j][e]})
instead of Object.value(jambArr[j])
? But I'm not sure whether the result of modified body.replaceText()
is what you want. If the result was not what you want, can you provide the detail information about the result you want?– Tanaike
Nov 16 '18 at 22:37
1
1
Yes,
Object.values()
does not work because Google Apps Scripts roughly supports ES5 JavaScript, and this feature was not introduced until later. See: Which Edition of ECMA-262 Does Google Apps Script Support?– Dustin Michels
Nov 16 '18 at 23:10
Yes,
Object.values()
does not work because Google Apps Scripts roughly supports ES5 JavaScript, and this feature was not introduced until later. See: Which Edition of ECMA-262 Does Google Apps Script Support?– Dustin Michels
Nov 16 '18 at 23:10
add a comment |
1 Answer
1
active
oldest
votes
As mentioned in the comments, GAS doesn't support Object.values but it does support Object.keys so you can iterate over the keys to get the array of Object values.
Replace
Object.value(jambArr[j])
with
Object.keys(jambArr[j]).map(function(e) {return jambArr[j][e]}).join(", ")
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53346016%2fget-all-object-properties-from-an-array-of-objects%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
As mentioned in the comments, GAS doesn't support Object.values but it does support Object.keys so you can iterate over the keys to get the array of Object values.
Replace
Object.value(jambArr[j])
with
Object.keys(jambArr[j]).map(function(e) {return jambArr[j][e]}).join(", ")
add a comment |
As mentioned in the comments, GAS doesn't support Object.values but it does support Object.keys so you can iterate over the keys to get the array of Object values.
Replace
Object.value(jambArr[j])
with
Object.keys(jambArr[j]).map(function(e) {return jambArr[j][e]}).join(", ")
add a comment |
As mentioned in the comments, GAS doesn't support Object.values but it does support Object.keys so you can iterate over the keys to get the array of Object values.
Replace
Object.value(jambArr[j])
with
Object.keys(jambArr[j]).map(function(e) {return jambArr[j][e]}).join(", ")
As mentioned in the comments, GAS doesn't support Object.values but it does support Object.keys so you can iterate over the keys to get the array of Object values.
Replace
Object.value(jambArr[j])
with
Object.keys(jambArr[j]).map(function(e) {return jambArr[j][e]}).join(", ")
answered Nov 17 '18 at 14:22
Amit AgarwalAmit Agarwal
5,63711326
5,63711326
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53346016%2fget-all-object-properties-from-an-array-of-objects%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Object.value? Link documentation on such method.
– TheMaster
Nov 16 '18 at 22:35
1
Unfortunately,
Object.values()
cannot be used at Google Apps Script yet. So how about usingObject.keys(jambArr[j]).map(function(e){return jambArr[j][e]})
instead ofObject.value(jambArr[j])
? But I'm not sure whether the result of modifiedbody.replaceText()
is what you want. If the result was not what you want, can you provide the detail information about the result you want?– Tanaike
Nov 16 '18 at 22:37
1
Yes,
Object.values()
does not work because Google Apps Scripts roughly supports ES5 JavaScript, and this feature was not introduced until later. See: Which Edition of ECMA-262 Does Google Apps Script Support?– Dustin Michels
Nov 16 '18 at 23:10