JSL
JSL8mo ago

JSL - HeyWith say a GPT user prompt, how can ...

Hey With say a GPT user prompt, how can I insert a variable from a previous node if it's not null. So "emails: + emailNode else "n/a" if null?
Solution:
This only works for undefined variable or null values, not undefined node, undefined node will never gets executed, you can get the type of data but not a node, I would recommend to use Switch instead of Branch in this case where it will call only the case matched.
Jump to solution
6 Replies
JSL
JSLOP8mo ago
thanks for any assistance
Gaurav Chadha
Gaurav Chadha8mo ago
Hi @JSL, You can use ternary operator in this case - email ? (x)email : "no email"
No description
Gaurav Chadha
Gaurav Chadha8mo ago
In my data the last name was empty, so ternary operator evaluates the field, if null then show added string. More about ternary operator - link.
No description
JSL
JSLOP8mo ago
Would that work for a undefined node, I have a couple of branches so the node with the data may not always be called. This is where I am running into the issue. I tried typeof {node} !== 'undefined' however it still responded with cannot read undefined node
Solution
Gaurav Chadha
Gaurav Chadha8mo ago
This only works for undefined variable or null values, not undefined node, undefined node will never gets executed, you can get the type of data but not a node, I would recommend to use Switch instead of Branch in this case where it will call only the case matched.
JSL
JSLOP8mo ago
thanks Gaurav