A navigation menu has 2 items called HR and Finance. I want to be able to restrict a users access to either of these menu items at runtime based on which department they are logging in with.
By default, a logged on user will see both the HR and Finance menu item
At design time, we are able to restrict access to navigation menu items. I have configured by HR navigation menu to be accessed by everyone except users in the “NotAllowedHr” group
And I allowed everyone to access the Finance navigation menu except users in the “NotAllowedFinance” group
By default the “NotAllowedFinance” and “NotAllowedHR” groups will have no members.
On my Logon form at design time, I have configured the below actions when we login to KTA.
The calls executed as follows:
- If Finance department selected, add logged on user to the NotAllowedHr group via the AddWorkerGroupResourceMember() method
- If Hr department selected, add logged on user to the NotAllowedFinance group via the AddWorkerGroupResourceMember() method
- Redirect to default form
Logon logic would need to be extended to remove the users from any groups they already belong to.
At runtime, I login and select the Hr department
This results in only the HR navigation menu being shown at runtime. The finance menu is not shown as the user is a member of the NotAllowedFinance group. This group is restricted from viewing the finance menu