Debugging - Js expression error

Describe the problem/error/question

I have a two step automation that triggers from an email received (Gmail) and writes to a Google sheet.

In the Google sheet step, I am cutting the datestring out of the ISO datetime as follows:

{{ $'T')[0] }}

I get a preview of the correct output value like 1/18/2024 as expected. I also see the expected value in the target spreadsheet when I run “Test Step” by itself.

However, when I run the pipeline from the canvas via “Test Workflow”, the value comes through blank.

This is my first time using n8n and I don’t know how to debug this effectively.

What is the error message (if any)?

Please share your workflow

Share the output returned by the last node

I’ve also noticed a discrepancy between the single step run and the workflow run as follows:

If I drop the split expression, ie a simple {{ $ }}, i get the following results:

Single step: 2024-01-18T20:00:00.000Z
Whole workflow: “2024-01-18T20:00:00.000Z”

Information on your n8n setup

  • n8n version: Version 1.24.1
  • Running n8n via: cloud

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hey @pinkbird,

Welcome to the community :tada:

What you are doing looks good to me, It shouldn’t matter but have you tried adding .toString() to the end to see if that helps?

Thanks @Jon I tried that but still seeing the same result. It works as expected when I run the append sheet step in isolation, but when I run the whole workflow, that cell is blank.

Any idea why the output might be diverging running as a single step vs the workflow?

Hey @pinkbird,

I know we have had issues in the past where something is different when ran in the front end and when in the background this could be another example of that.

What about doing it the other way and going with {{ $'T')[0] }}? I do have a dev ticket open somewhere for a similar issue so it could be that when that is fixed this will also be fixed, I will do some testing later today and see if I can reproduce this.

hey @Jon thank you, ... fixed the bug, although I am still seeing divergent values:

Single Step: 1/26/2024
Whole run: Fri Jan 26 2024 23:00:00 GM

Close enough for my purpose though. Would be interested to follow up when that other bug you mentioned is addressed.

Thanks again!

1 Like

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