I am creating a navigation menu, and what I am trying to do is if the user is not an admin, then show one menu, and if they are an admin, show a different menu. I have tried several other ways to do this but with no success.
If(!IsBlank(MicrosoftEntraID.CheckMemberGroupsV2(User().Email, ["xxxx-xxxx-xxxx"]).value), Set(varIsAdmin, false), Set(varIsAdmin, true));
If(IsBlank(varIsAdmin),
colSidebarMenu(
Table(
{Value: "Home", Icon: Icon.Home, Screen: Home},
{Value: "Add/Edit Pubs", Icon: Icon.Tablet, Screen: EditPubs},
{Value: "Create/Edit Rept", Icon: Icon.DocumentWithContent, Screen: Reports},
{Value: "Report Status", Icon: Icon.ListWatchlistRemind, Screen: ReportStatus},
{Value: "Search Abstract", Icon: Icon.Search, Screen: Search},
{Value: "Late PI Proj. Rpts", Icon: Icon.LevelsLayersItems, Screen: LatePI},
{Value: "Create/Edit Abst.", Icon: Icon.Document, Screen: Abstract},
{Value: "My Profile", Icon: Icon.Person, Screen: Profile}
)
),
colSidebarMenu(
Table(
{Value: "Home", Icon: Icon.Home, Screen: Home},
{Value: "Add/Edit Pubs", Icon: Icon.Tablet, Screen: EditPubs},
{Value: "Create/Edit Rept", Icon: Icon.DocumentWithContent, Screen: Reports},
{Value: "Report Status", Icon: Icon.ListWatchlistRemind, Screen: ReportStatus},
{Value: "Search Abstract", Icon: Icon.Search, Screen: Search},
{Value: "Late PI Proj. Rpts", Icon: Icon.LevelsLayersItems, Screen: LatePI},
{Value: "Create/Edit Abst.", Icon: Icon.Document, Screen: Abstract},
{Value: "My Profile", Icon: Icon.Person, Screen: Profile},
{Value: "Admin", Icon: Icon.Lock, Screen: Admin}
)
)
);
Your code looks good, but you can make it more readable by doing the following:
If(!IsBlank(MicrosoftEntraID.CheckMemberGroupsV2(User().Email,
["xxxx-xxxx-xxxx"]).value),
Set(varIsAdmin, false), Set(varIsAdmin, true)
);
colSidebarMenu(
Table(
{Value: "Home", Icon: Icon.Home, Screen: Home},
{Value: "Add/Edit Pubs", Icon: Icon.Tablet, Screen: EditPubs},
{Value: "Create/Edit Rept", Icon: Icon.DocumentWithContent, Screen: Reports},
{Value: "Report Status", Icon: Icon.ListWatchlistRemind, Screen: ReportStatus},
{Value: "Search Abstract", Icon: Icon.Search, Screen: Search},
{Value: "Late PI Proj. Rpts", Icon: Icon.LevelsLayersItems, Screen: LatePI},
{Value: "Create/Edit Abst.", Icon: Icon.Document, Screen: Abstract},
{Value: "My Profile", Icon: Icon.Person, Screen: Profile}
)
);
If(varIsAdmin,
Patch(colSidebarMenu, Defaults(),
{Value: "Admin", Icon: Icon.Lock, Screen: Admin}
)
);
This will create your table with default options, and if the current user is admin, one more value will be patched if Admin
.