• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Creating an App.Alert Based on Two Different Criteria

Community Beginner ,
Sep 08, 2021 Sep 08, 2021

Copy link to clipboard

Copied

Hello,

 

I need a calculated field total be less than 80 AND value in another field. It works perfectly when I make the value rise above 80, but I can't get it to also take into account the other field, which happens to be 60 at the moment. Below is the code I have currently:

 

var v1 = getField("Module Adjusted VOC").value;

 

if(event.value < 0 || event.value > 80)

{

app.alert("Module Adjusted VOC must be less than the Microinverter Max DC Input Voltage with 80V AFCI Cap. Otherwise, this Standard Plan cannot be used.",0);

event.target.textColor = color.red;

}

else

{

event.target.textColor = color.black;

}

if(event.value > getField("Inverter Max DC Input Voltage"),value) { app.alert("Module Adjusted VOC must be less than the Microinverter Max DC Input Voltage with 80V AFCI Cap. Otherwise, this Standard Plan cannot be used.",0);

}

else

{

event.target.textColor = color.black;

}

TOPICS
Create PDFs , General troubleshooting , JavaScript , PDF forms

Views

1.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Sep 08, 2021 Sep 08, 2021

Just add it as another OR condition to the first if-statement:

 

if(event.value < 0 || event.value > 80 || event.value > Number(this.getField("Inverter Max DC Input Voltage").valueAsString)) {
	app.alert("Module Adjusted VOC must be less than the Microinverter Max DC Input Voltage with 80V AFCI Cap. Otherwise, this Standard Plan cannot be used.",0);
	event.target.textColor = color.red;
} else {
	event.target.textColor = color.black;
}

 

Votes

Translate

Translate
Community Expert ,
Sep 08, 2021 Sep 08, 2021

Copy link to clipboard

Copied

Just add it as another OR condition to the first if-statement:

 

if(event.value < 0 || event.value > 80 || event.value > Number(this.getField("Inverter Max DC Input Voltage").valueAsString)) {
	app.alert("Module Adjusted VOC must be less than the Microinverter Max DC Input Voltage with 80V AFCI Cap. Otherwise, this Standard Plan cannot be used.",0);
	event.target.textColor = color.red;
} else {
	event.target.textColor = color.black;
}

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 08, 2021 Sep 08, 2021

Copy link to clipboard

Copied

LATEST

Works perfectly, thank you! 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines