I was creating an automation where I could optionally supply a YT URL and extract captions. However I came up against an issue later down the line where IF I conditionally skipped this node the automation would fail as the node was never executed.
The accepted resolution was that there was no solution “Currently there is no other way. If you will try to refer to any node, that hasn’t been executed, you will receive that error.”
Ultimately I solved the issue as I needed to initially check whether the value was undefined. Using the below JS I was able to solve the above issue.
{{
(() => {
try {
const val = $('Webhook').first().json.youtubeCaptions;
return (val === undefined ? 'Not Available' : val);
} catch(e) {
return 'Not Available';
}
})()
}}