Best answer

Javascript: How can I catch 'undefined' before it errors

  • 21 October 2020
  • 4 replies
  • 957 views

Userlevel 2

Probably a simple fix. I am expecting a value, but occassionally the data is undefined because of empty data. I would like Javascript code step to catch it instead of the zap erroring out. Any tips to use IF statement or another method to catch an undefined before it errors the code step when I use .length on it.

error when estimateid is undefined
 
current code. works fine unless the Estiamtes ID is undefined

 

icon

Best answer by olivialook 21 October 2020, 17:46

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

4 replies

Userlevel 2
Badge +1

Would it work in your flow to use a JS try...catch here? 

Userlevel 2

Would it work in your flow to use a JS try...catch here? 

I will give that a try, thank you!

Userlevel 2

I will have to wait to see if this will work with actual data. but THANK YOU.

 

Userlevel 2

Would it work in your flow to use a JS try...catch here? 

I will give that a try, thank you!

WORKING PERFECTLY. Thank you. Zap does not error our now, it outputs 0 if the data is undefined.