1
0
-1

Hi, I am wanting to do a viability rule based on a if/else statement using data fields and need some java script. 

e.g. if datafield 1 = true, then show,

else datafield 2 = true, show,

else datafield3 = true, show. 


Can you please help with the scripting. 

Thanks, 

hannah 

    CommentAdd your comment...

    1 answer

    1.  
      1
      0
      -1

      Hi Hannah,

      The JavaScript you'll need will look something like this:

      if(data.field1 || data.field2 || data.field3){
      	return true;
      }
      return false;

      This reads "If field1 OR field2 OR field3 are equal to true, then return true (visible), otherwise return false (hidden). This code assumes that these values are Boolean (they only contain true or false values).

      If you want to check for a specific value in each field you would write something like this:

      if(data.field1 === "Green" || data.field2 === 3 || data.field3 === false){
      	return true;
      }
      return false;

      This reads "If field1 is exactly equal to the text value "Green" OR field2 is exactly equal to the numeric value 3 OR field3 is exactly equal to the boolean value false, then return true (visible), otherwise return false (hidden).

      Hope this helps, let me know if you need a more specific example.

      CommentAdd your comment...