Reputation: 57
The API I am accessing has an array (tickets
), that contains a nested array of strings (tags
). When I loop through to get to the nested array values, I am able to see the full list of tags (in the red box of the screenshot below).
When I view the sheet, however, it is only returning the first item of the array as you can see in the below screenshot.
I am sure this is something silly, but I cannot figure it out. My code is below. Thank you for any help you can provide.
var example = []
results.forEach(function(tickets){
var temp = [];
tickets.tags.forEach(function(tags){
temp.push(tags);
})
example.push([tickets["resolution_time"],tickets["created_at"], tickets["priority"], tickets["state"],tickets["id"], tickets["closed_by"], temp])
})
Logger.log(example + "is this working?");
var len = example.length;
//clear existing data
sheet.getRange(2,1,2000,8).clearContent();
//paste in the values
sheet.getRange(sheet.getLastRow() +1,1,len,7).setValues(example);
Upvotes: 1
Views: 87
Reputation: 14679
I see you trying to put an array of strings (temp
) into a single cell of the sheet. Can you even do that?
Replace
var temp = [];
tickets.tags.forEach(function(tags){
temp.push(tags);
})
with
var temp = tickets.tags.join(',')
Upvotes: 2