Perspective Binding configuration IF statement not working

Hi, I have 3 user roles( administrator, users, member ), this code is behind the binding of a visible property of a label which says “Users”, “Administrator” or “Member” based on what you are logged in as. I want the label to be invisible if you are not logged in as any of the roles but its not working with what i have at the moment. Any help is welcome, thanks.

if(({this.props.text} != "Administrator") || ({this.props.text} != "Users") || ({this.props.text} != "Member"), false,true)

It sounds like you want logical AND instead of logical OR. Replace || with &&.

A little prettier formatting:

if(
    ({this.props.text} != "Administrator")
        && ({this.props.text} != "Users")
        && ({this.props.text} != "Member"),
    false,
    true
)
1 Like

I think @zacht is correct, and this would be more clear if you reversed your logic:

if(({this.props.text} = "Administrator") || ({this.props.text} = "Users") || ({this.props.text} = "Member"), true,false)
1 Like

You can also ditch the pointless if call, since the = operator already returns a boolean result:
{this.props.text} = "Administrator" || {this.props.text} = "Users" || {this.props.text} = "Member"

4 Likes

Hi Zacht, I ran it there and works perfectly, thanks very much.