Question

IF/ Else Statement in JavaScript

  • 11 September 2023
  • 1 reply
  • 58 views

Userlevel 3
Badge +3

I am getting comfortable with IF/ Then Statements in my ZAPS but I an trying to do this IF/ ELSE statement and I cannot seem to get it to work.

Verbally my statement goes like this: “If UDS is an empty cell, then the value to output is 99999 otherwise output 80307”

Code wise it looks like this:

let UDS = inputData.UDS; 
let EM = ""; // sets a blank value
if (UDS=" ") {EM = "99999";} 
else {EM = "80307";}
output = [{UDS, EM}];

 

For some reason, I cannot get the else part of this code to output the correct result.  

The issue is this: when attempting to identify an empty cell (i.e., no data), the if / then statement yields an error when using spreadsheet style formulas so I thought I would use the IF/ Else statement to get around this issue by creating an input when the correct value does not exist (so the ZAP keeps running)

Help please!!  I have diligently read all of the support materials in this Community multiple times!!

Thanks!!

 

gml

 


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

1 reply

Userlevel 7
Badge +14

Hi @blueguy 

Good question.

Try changing it to this:

if (UDS == "" || UDS == null) {EM = "99999";} 

 

You can also ask ChatGPT for help with JavaScript.