arode
Novice

Nested AND OR statements break form

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?

0 Kudos
Reply
1 Reply
MegaJerk
Collaborator

Re: Nested AND OR statements break form

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:

MegaJerk_0-1653115510659.png

 


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:

MegaJerk_1-1653115770032.png

 

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.

 

 

0 Kudos
Reply