Skip to main content
kenneth kam chuh21426993
Known Participant
January 19, 2023
Answered

Pass or Fail condition - what if cell is blank?

  • January 19, 2023
  • 2 replies
  • 652 views

I have a rule for a product to pass or fail to be used.

The rule is if >30, then the product is failed and if <= 30, the product is passed.

 

I have the following script that works well.

 

var pf1 = this.getField("Product").value
if (Number(pf1)<=30){event.value = "Pass";}

if (Number(pf1)>30){event.value = "Fail";}

 

However, when I leave the cell unfilled, then the default of this product is set as "Pass" and I don't want this. I want the default setting as "" (blank) when the cell does not contain any number. 

 

Anyone can help me with this? Cheers

This topic has been closed for replies.
Correct answer Nesa Nurani

You can use like this:

var pf1 = Number(this.getField("Product").valueAsString);
if(pf1){
 if(pf1<=30)
 event.value = "Pass";
 else
 event.value = "Fail";}
else
event.value = "";

2 replies

try67
Community Expert
January 19, 2023

Can the value of the cell be zero?

Nesa Nurani
Nesa NuraniCorrect answer
Community Expert
January 19, 2023

You can use like this:

var pf1 = Number(this.getField("Product").valueAsString);
if(pf1){
 if(pf1<=30)
 event.value = "Pass";
 else
 event.value = "Fail";}
else
event.value = "";
kenneth kam chuh21426993
Known Participant
January 20, 2023

Thanks heaps! This works perfectly.

 

Can you explain what is the purpose of the first if(pf1){  

 

if(pf1){ if(pf1<=30)
 event.value = "Pass";
 else
 event.value = "Fail";}
else
event.value = "";