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;
}
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;
}
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;
}
Copy link to clipboard
Copied
Works perfectly, thank you! 🙂