I have a frameset where I am using a computed view if a person is not 1 of the 3 user roles I have defined. Every time I add the @if statement I am getting the statement below. However if I remove the ! from the statement the formula works. This type of format has worked before and also works in my outline but not in the frameset.
passing arguments to a non-@function or to an @function that doesn’t require arguments
*** Not working ***
@If(!(@Contains(@UserRoles; “Admin”:“TPAdmin”:“TPEditor”);“(DenyAccess)”;“Test”))
*** Working *** but not what I want
@If(@Contains(@UserRoles; “Admin”:“TPAdmin”:“TPEditor”);“(DenyAccess)”;“Test”)
Subject: Extra brackets in the wrong place - just remove them
In the version where you’re using “!”, the last closing bracket is in the wrong place. Those extra brackets actually aren’t needed at all, so this should work:@If(!@Contains(@UserRoles; “Admin”:“TPAdmin”:“TPEditor”);“(DenyAccess)”;“Test”)
Also, though it might not matter in this case, you should note that @Contains isn’t the best function to use.
@Contains returns true if any substrings are found in a string. It just happens to work because the substrings you’re checking are in the role names.
An example of where it would cause a problem is if you only wanted to check for the “Admin” role and weren’t interested in other roles. If a user has the “TPAdmin” role but does not have the “Admin” role, this statement would return true because “Admin” is a substring of “TPAdmin”:
@Contains(@UserRoles; “Admin”)
If you want want an exact match on role names, check Designer Help for @IsMember and @IsNotMember, and also note that the role names returned by @UserRoles are always enclosed in square brackets (e.g. “[Admin]”).