Google Sheet trigger - SMTP - old/new values

I have a simple workflow that is almost working, there’s just one part I can’t seem to get working.

My flow is as simple as:

[Google Sheets Trigger] → [Send Email]

It connects fine, it lists all of the data in the sheet I select, everything…perfect. I select the option “Include in Output: Both versions” as I would like the old value and new value.

In the SMTP node, in the text of the email, how am I supposed to get the Old and New variables of the record/cell that has changed?

If I do this:

Item has been changed on Sheet 2:

{{ $json.FirstName }}
{{ $json.LastName }}

I get an email that simply contains:

Item has been changed on Sheet 2:

And nothing more.

There are 2 records in this sheet but only 1 field has been changed, so I would like it to say something like:

Item has been changed on Sheet 2:
LastName: Was ‘poppins’
LastName: Now ‘blobbins’

How can I achieve this? I presume it’s currently blank because I’m not specifying which version I would like data for but how do I get the values?

If I change the option to just “New Values” (or “Old Values”) then it works fine but obviously only gives me the value it has been changed to and not what it was previously. I’d imagine there’s something like {{ $json.FirstName.oldValue }} and {{ $json.FirstName.newValue }} to actually get what I need but I can’t find it.

Just to confirm; this is when the task runs automatically, I am not trying to get the old/new values from within the editor as I know it doesn’t work in that scenario. It is when it is saved and active and naturally runs.

Thank you for any help/assistance with this!

I’ve figured it out, thanks.


Hey @aurora,

That is great news, What did you do in the end?

As I’m new to N8N, I didn’t realise you could inspect the JSON in the execution. Once I done this, I could see the JSON object keys and values so I could specify what I wanted. To make things quick for anyone else having this issue, here you go:

Changed field:

Previous value:

Current value:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.