3 Replies Latest reply on Feb 3, 2016 3:37 PM by Vaughan

    Using an OR statement to hide an object

    jdevans

      I have a button on a layout I'd like to hide to every account except for two. My logic was to use the "Hide object when" calculation engine.

       

      When I set it to hide under the following condition, it works:

       

      Get(AccountName) doesn't equal "AdminAccount"

      meaning: it is visible to AdminAccount, but nobody else. (good)

       

      But if I add a second account separating them with the word "or" like so:

      Get(AccountName) doesn't equal "AdminAccount or

      Get(AccountName) doesn't equal "user1"

       

      the object disappears even for "AdminAccount"

       

      Why doesn't this work?

       

      BTW, I tried xor as well, and it still hides the object to either account.

       

      NOTE: the actual code uses the not-equal-to symbol inside the calculation engine in place of "doesn't equal" above.


      Also, I would've used Get(AccountPrivilegeSetName) but I would've had to do an or statement with that too, since the two users I want to SEE the object have different privilege sets.

       

      Message was edited by: Dave Evans

        • 1. Re: Using an OR statement to hide an object
          Extensitech

          You want an and, not an or.

           

          get ( accountname ) <> "AdminAccount" AND Get(AccountName) <> "user1"

           

          In other words, it doesn't equal one AND ALSO doesn't equal the other,. If it equals either one of them, you want the button.

           

          Every account is going to be unequal to at least one of your options. For example, with an or, "user1" doesn't equal "AdminAccount", so one of your conditions is true, so your "or" is true.

           

          btw If you use "<>" instead of the fancy equals with a slash in it, it's (easily) typable and means the same thing.

           

          Also, it's better to manage these things at the privilege set level, even if it means there's only one user in the priv set. Chances are, another person will come along that needs the same privs, anyhow. Also, you can assign extended privs to priv sets, to take it to an even higher level, as you noted.

           

          Chris Cain

          Extensitech

          • 2. Re: Using an OR statement to hide an object
            jdevans

            Thank you! In my mind, it made no logical sense to use AND. I am still having a little trouble getting my mind around it. It doesn't follow what I would consider to be normal AND behavior. In my mind AND would always fail because it seemed to mean Get(AccountName) would have to be true simultaneously for both accounts...which is not possible since you can only see a given layout as a single user.

             

            But it works now, and I will re-read this a few times to see if I get why.

            • 3. Re: Using an OR statement to hide an object
              Vaughan

              jdevans wrote:

               

              Thank you! In my mind, it made no logical sense to use AND.

               

              It could also be expressed as:

              NOT ( get ( accountname ) = "AdminAccount" OR Get(AccountName) = "user1" )