How can i add if condition inside expressions value.
I want to retrieve a value checking is that node is different from null or “not found” then retrieve from another node.
In the below case i want to retrieve from specific node if it has value.
Is it possible?
Something like this.
if {{$node[“Merge”].json[“subject”]}}!=“not found”
return {{$node[“Merge”].json[“subject”]}}
if {{$node[“Merge1”].json[“subject”]}}!=“not found”
return {{$node[“Merge1”].json[“subject”]}}
Having a similar issue and ending up adding a code node in between my filter node and the HTTP request node but thought it would be possible to use a ternary operator or the if condition above to dynamically replace “undefined” values when generating an HTTP POST Request so that it is formatted properly straight in the HTTP Request node expression.
The idea is to use this expression in the the HTTP Request node to dynamically check if the properties requested in the data input exist or are null/empty and if so to populate the resulting JSON payload with either empty strings (if they are text data type) or 0 values if they are numbers/dates. If the properties have values to just copy them.
Unfortunately it always comes up with some “undefined” values and makes the HTTP post request fail due to the syntax error. Is there not a way of doing this in an expression that I may be missing?
Here is a sample of the expression I was using:
{
“wse_hs_analytics_source_data_2”: {{$node[“Filter for Course Finder”].json[“body”][“properties”][“wse_hs_analytics_source_data_2”][“value”] !== undefined ? $node[“Filter for Course Finder”].json[“body”][“properties”][“wse_hs_analytics_source_data_2”][“value”] : “”}},
“wse_first_conversion_date”: {{$node[“Filter for Course Finder”].json[“body”][“properties”][“wse_first_conversion_date”][“value”] !== undefined ? $node[“Filter for Course Finder”].json[“body”][“properties”][“wse_first_conversion_date”][“value”] : null}}
}
Hi @MartechNomad - sorry to hear you’re running into this! As this topic is quite old, could you please make a new thread and fill in the template that comes along with it fully? There may be a different issue at play given how many changes have been made to n8n in two years