No clue how I messed up the Admin role

My app have 4 roles: Admin, Vendor, Manager, Employee

I feel incredibly stupid. I have been trying to find out why all of a sudden, the Admin role currently functions like an Employee. This is the expression I put into the Security filter, pretty much copied from this: https://youtu.be/2Z2qUTtxNFA?t=1677

IFS(

OR(

ANY(Current_User[Role])="Admin",
ANY(Current_User[Role])="Vendor"

),
TRUE,
ANY(Current_User[Role])="Manager",
OR(

[User_Email]=USEREMAIL(),
AND(

[User_Email].[Management]=ANY(Current_User[Management]),
[User_Email].[Role]="Manager"
[User_Email].[Role]="Employee"

)

),
TRUE,
[User_Email]=USEREMAIL()

)

I've tried troubleshooting the following:

  • If I take away the entire security filter, all roles work like it did before I applied the filter. So I believe the issue is in the security filter.
  • Tested that the vendor role works as intended with the filter, since it's pretty much identical to the Admin line.
  • Tried replacing the role "Admin" with "Super Admin," just in case I somehow restricted the Admin role somewhere in the app. Super Admin worked like faulty Admin/ Employee role. 
  • If I take away "ANY(Current_User[Role])="Admin",", nothing noticeable has changed, which leads me to think that it's functioning according to this line: "TRUE, [User_Email]=USEREMAIL()"

I am baffled because it seems very straight forward, and I've combed through the syntax.

EDIT: Solved Bonus Question
Bonus Question:
So I want to make it so that Managers can see other Managers' orders. It works in this code if I leave out "," in the expression:

AND(

[User_Email].[Management]=ANY(Current_User[Management]),
[User_Email].[Role]="Manager"
[User_Email].[Role]="Employee"

)

But if I add "," after "[User_Email].[Role]="Manager"", then it suddenly doesn't show ANY Manager orders and only Employee orders. I'm glad I can get it to work. But I don't understand how. If someone don't mind taking the time to explain, I would like to know.

Solved Solved
1 9 200
1 ACCEPTED SOLUTION

The answer is going to be highly specific to your data and how you put things together;  most likely it's a type issue, that's why things aren't working how you're wanting.

No easy way to troubleshoot stuff like this; best approach is to strip out each part of your formula and test them individually.  If they all work alone, then start combining them together to see what clashes with what.

Takes time, but you're getting better at formulas the whole time - so there's that at least. ๐Ÿ˜‰

View solution in original post

9 REPLIES 9

Not having the "," is incorrect, it simply ignores that portion after the missing comma.  Why the expression assistant is not flagging it as an error I am not sure.

I believe you  need to remove the [User_Email].[Role]="Employee" portion.  It doesn't make sense in this context to have a check for BOTH "Manager" and "Employee" - in most apps a person can only be one or the other - not both.

It doesn't work after adding the "," because the expression is checking [User_Email].[Role] to be both values and obviously it cannot be both at the same time.

Maybe something like this to simplify things?

SWITCH(ANY(Current_User[Role]),
	"Admin", True,
	"Vendor", true,
	"Manager", 
		OR(
			[User_Email]=USEREMAIL(),
			AND(
				[User_Email].[Management] = ANY(Current_User[Management]),
				[User_Email].[Role] = "Manager"
			)
		),
[User_Email]=USEREMAIL()
)

Omg! Hi! Thanks for all that you do! I've learned so much from your videos.

I actually started out trying SWITCH(). Unfortunately, that expression also doesn't work, which I also do not understand why since it looks very straightforward too. It actually didn't consider any of the user's roles when I tested it with "Preview App as".

BTW... Love the name.  #HadMeRollin!!!

Thank you ๐Ÿ˜ 

It seems like there's no clear solution. Is there anything anyone can possibly point me in the right direction so I can learn more or consider to see if I can troubleshoot?

Also, somehow the filter stop considering the manager role and won't let them see the employees in their management group. I haven't changed the filter. But I have deleted it so I can edit and paste it back several times. 

The answer is going to be highly specific to your data and how you put things together;  most likely it's a type issue, that's why things aren't working how you're wanting.

No easy way to troubleshoot stuff like this; best approach is to strip out each part of your formula and test them individually.  If they all work alone, then start combining them together to see what clashes with what.

Takes time, but you're getting better at formulas the whole time - so there's that at least. ๐Ÿ˜‰

Thank you for the insight and direction. I definitely don't have enough experience yet to even have the instinct on how to begin. 

Top Labels in this Space