Describe the problem/error/question
Hi everyone,
I’m working on a workflow in n8n and I need help writing a conditional expression.
What I want to do:
Inside an expression (used in an HTML field), I want to check if a certain item exists — for example, an image coming from an Airtable field. If it exists, I want to generate an HTML link using its filename. If it doesn’t, I want to display a fallback message.
For example:
- If
$('Airtable').item.json['Photo'][0].filenameexists, then output something like:
<a href="logo_url">filename</a> - Else, show:
<span style="color: red;">We don’t have your logo image.</span>
I tried different syntaxes using ternary operators and optional chaining (?.), but I can’t seem to get it working correctly inside an n8n expression.
Important: I would like to do this directly in the expression, not by using an additional Function or IF node, because I need to repeat this kind of logic in multiple places, and using extra nodes would make the workflow too complex.
Could someone help me write the correct expression for this kind of logic?
Thanks a lot in advance! ![]()