Append log send email to Google Sheets envelope field not full!

I want to record send email log to Google Sheets by append, but in n8n log show like this

But in Google Sheets envelope field record like this


How to receive full data in envelope field?

Hey @huuich!

How are you appending the data? You can select either Raw or User Entered from the Value Input Mode additional option. You can read more about it in the FAQs section.

In this case do sadly not think that the Value Input Mode. The only way is probably to stringify the variable yourself via a Function-Node with the following code:

items[0].json.envelope = JSON.stringify(items[0].json.envelope);
return items;
1 Like

That’s working ok, thank you. Could you explain a bit more detail about this code and the reason above code is ok?

What the code is doing is converting a JavaScript object into a string. By default does JavaScript return [object Object] when it is told to make “text” out of an object. With JSON.stringify we do that manually “the proper way”.

Hope that makes sense.

1 Like

@jan This code is ok if I have 1 envelope value, but if I have more than 1 envelope value, only first value return text, other values return [object Object] How can I return text to all values?

Hey @huuich,

You can use the following code snippet in the Function Item node:

item.envelope = JSON.stringify(item.envelope);
return item;

This will take each item, and process them one at a time. Another approach is to create a loop in the Function node and process the items.

1 Like

I’ve used this code but return “ERROR: item is not defined”, how can I fix this?

Hey @huuich,

Here’s an example workflow that might help:

@harshil1712 It’s ok now, that’s is my mistake, I’ve used your code in Function node not Function Item node. Can you guide me an example use Function node and process the items like code above? Thanks!

Hey @huuich,

You can use the following code in the Function node

for (item of items) {
  item.json.newMessage = JSON.stringify(item.json.message);

return items;
1 Like

@harshil1712 Working like a charm, thank you for your detailed instructions!

1 Like