How do I remove empty lines

Describe the problem/error/question

How do I remove [undefined] lines in expression? My goal is to remove empty lines that have no data.

What is the error message (if any)?

Please share your workflow

Woocommerce orders ----> Discord channel message

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

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

Welcome to the community @woon8n!

Sadly very hard to answer that question without more context. How does the incoming data look like? Can you please provide an example. Thanks!


Hi, thanks for the welcoming. sorry for the late response looks like I didn’t have email alerts set to always on. Here is a image of the data I’m trying to use.

Hi @woon8n, you can probably use the conditional operator to solve this problem. Check if your field is “truthy” (meaning not undefined, null, etc). If so, return the actual field value with a line break, if not return an empty string instead.

Something like this (of course instead of ... you want to use your full expression, I just couldn’t copy it from your screenshot):

{{ $('WooCommerce Trigger').item... ? $('WooCommerce Trigger').item... + "\n" : "" }}

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