Expand my Community achievements bar.

2 conditions 1 result

Avatar

Former Community Member
Hope someone can help me. Here is the code I am using:



if (PressureRea1 >= PressureReq1 and DurationHeld1 >= DurationReq1) then

Results1 = "PASS, No leakage detected"

else

Results1 = "FAIL, See additional comments"

endif



As you can see, what I want to happen is, If the number in Pressure Rea1 is greater than or equal to the number in PressureReq1 AND the number in DurationHeld1 is greater than or equal to the number in DurationReq1 I want the results field to indicate a PASS status. If either of these conditions are less than the other, then I want to have the results field indicate a FAILED status.



When inputting the numbers in PressureRea1 and PressureReq1 I get the appropriate response in the Results field, however when changing the numbers in the Duration Fields, I cannot get a fail response.



Am I forgetting to add something?
5 Replies

Avatar

Level 5
Looks like you are using FormCalc code and unlike JavaScript FormCalc can not self convert data types. Code looks OK but make sure you explicitly convert datatypes rather than depend on system.



Also if you can use JS code it will convert data types by it self.

then code will look like this

if (PressureRea1 >= PressureReq1 && DurationHeld1 >= DurationReq1) {

Results1 = "PASS, No leakage detected"

}else {

Results1 = "FAIL, See additional comments"

}



Good luck,

SekharN

Avatar

Former Community Member
SekharN,



Thanks for the response. Not sure what you meant about explicitly converting data types?



I tried out the JS code but still I cannot get it to respond with a fail if the DurationHeld1 < DurationReq1.



This is driving me crazy!

Avatar

Level 5
It hard to understand what is going wrong. Shoot me an email at meetsekharv@yahoo.com with your form and brief description what you want to achive and at what event?

Will fix it for you.

Avatar

Level 5
Here is the updated JS code for you....

You are trying to compare "5 min." to some numaric value which will fail due to conversion issues. Also you need to use the rawValue property of the object you can not just compare with object names.



var DReq1 = DurationReq1.rawValue

if (!DurationReq1.isNull) {

DReq1 = DReq1.replace("min.","")

}

if ((PressureRea1.rawValue >= PressureReq1.rawValue) && (DurationHeld1.rawValue >= DReq1)) {

Results1 = "PASS, No leakage detected"

}else {

Results1 = "FAIL, See additional comments"

}



Good luck,

SekharN

Avatar

Former Community Member
SekharN,



Thank you soooooooo much! This worked perfectly.