I have a node where the data set may be undefined. When this happens I need to have if statment within the expression to echo out something else. Not sure what I’m doing wrong. I’m sure its something simple.
{{ $if($json.data[9].litify_pm__Answer__c === "undefined","long strring x dont findanthing43234230432234", "test")}}
ive also tried
{{ $if($json.data[9].litify_pm__Answer__c === undefined,"long strring x dont findanthing43234230432234", "test")}}
Hi @Philip_Wiggins Would you happen to have another example of what you’re seeing, or perhaps a more direct one? When I’m running this, I’m seeing this:
@EmeraldHerald The problem occurs when its actually undefined. So in the sample data I gave there are 49 objects. The Google Docs node I have it to set 10 data points for each batch and it errors when it tries to fill in the data for the 50th object. I’m doing this to update in batches of 10, but my data set could be any number of “questions and answer” sets so I expect sometimes to receive undefined. In the sample I gave you if you made it only 9 objects you should get the error. Below you can see if its not undefined the conditional works, but if its actually undefined, it doesn’t.
I’ve also updated the JSON link to have 9 objects instead of 49 so it doesn’t actually have to go through the batches to see the issue.
Can you not check for undefined within the expression? Below is another example where you can see my issue using the $if condtional. I now that data[9] undefined here and when its undefined I want to be able to output something not undefined.
You might also be able to use something like {{ $if( $json.data[9]?.question === undefined, "1", "2" ) }} which seems to work in my testing for my test index 8 is the only one that contains any data.