Nested AND OR statements break form

  • 12 May 2022
  • 1 reply
  • 167 views

The following statement in a form control rule breaks the form upon rendering (blank page):

!UserEquals({Common:CurrentUser},personA)||(!equals(varB,"c")&&!equals(varD,"e"))||!equals(varF,"g")

 

While this one is working:
!UserEquals({Common:CurrentUser},personA)||!equals(varB,"c")||!equals(varF,"g")

 

Is it possible to nest an AND statement within an OR?


1 reply

Userlevel 5
Badge +14

You can absolutely nest ORs and ANDs in the way you are doing. 

here I have a Calculated Control with the following formula: 


(function(){
var personA = "domain\testUser";
var varB = "b";
var varD = "d";
var varF = "f";

return !userEquals({Common:CurrentUser}, personA) || (!equals(varB, "c") && !equals(varD, "e")) || !equals(varF, "g");
}())

 


So when the form loads it evaluates, and returns true because there is no such user called "domain\testUser", returning false, which then gets inversed (by way of the "!") into true, and returns:



 



To find out if something is broken in your instance, I would recommend pressing the F12 key in Chrome to open the Console so that you can see any errors that your Form may be producing whenever you try to preview it / load it in this state. 


 


An error will be highlighted in red with an "x" next to it:



 


I would also check to make sure that those variables contain the type of data that you're expecting them to contain. If there is something that might cause an error in a different function, it could prevent your form from loading silently. 


 


Without more information however, it is impossible to correct whatever might be happening in this case.


 


 

Reply