Skip to main content
Known Participant
August 19, 2020
解決済み

app.alert

  • August 19, 2020
  • 返信数 3.
  • 1157 ビュー

Hi,

I have field1 and 2. I have app.alert if both fields are 0 I get app.alert,
but if only 1 is not 0 alert shouldn't pop.
I'm getting alert until both field are not 0. How do i fix it?


if(this.getField("field1").value == 0 || this.getField("field2").value == 0 ) {
app.alert("Field1 or field2 need value greater then 0.");
}

このトピックへの返信は締め切られました。
解決に役立った回答 BarlaeDC

HI,

 

I think you are looking for AND rather than OR in your if statement :

 

if(this.getField("field1").value == 0 && this.getField("field2").value == 0 ) {
app.alert("Field1 or field2 need value greater then 0.");
}

 

Hope this helps

 

Malcolm

返信数 3

BarlaeDC
Community Expert
BarlaeDCCommunity Expert解決!
Community Expert
August 19, 2020

HI,

 

I think you are looking for AND rather than OR in your if statement :

 

if(this.getField("field1").value == 0 && this.getField("field2").value == 0 ) {
app.alert("Field1 or field2 need value greater then 0.");
}

 

Hope this helps

 

Malcolm

Marietaa作成者
Known Participant
August 19, 2020

Oh I was sure I tried it before, guess I didn't 🙂 thanks that helped a lot.

ls_rbls
Community Expert
Community Expert
August 19, 2020

A custom validation script  also worked for me:

 

 

if ( (event.value ==0) ||  ( this.getField("field2").value == 0 )) {

    app.alert("Invalid value for field. Field1 or field2 need a value greater than 0.");
    
     {if (event.value ==0) event.value =""; }
 
 }

 

 

Technical Generalist