Hi @arpost
Again, you cannot change the name so I am not sure why you repeated it. A role has a label and a name.
You can change the label, you cannot change the name. Changing the Name requires you to delete it and recreate it.
And this is the same model that exists because no matter what you do you would have to change it.
I have some code
Do I want the person to be able to run the code. To do that I have to check if they have the role. If you don't want to compare by "Label" which you keep calling name, then don't, compare by the schema logical name which won't change.
If you are adding more roles then you still have to put logic for them in the App.
If User has Role A
Run code
End if
But now I want Role B to also run it, so If User has Role A or Role B
But instead You could do this
If User Has a Role that can run this code
Run code
End if
Then have a list of roles that can run this code (or a security group)
Have your code validate that ANY of the roles exist in your "group/list"
SharePoint List
RoleA
RoleB
RoleC
Features A
RoleA
RoleC
Code
For Feature A who can run it
Then Check if any of their roles are in that list. Now you aren't comparing Role Names or Security Group Names, you are looking at a mapped list of Roles that can do that code.
Now you can change "labels" names add more whatever and it will instantly work without redeploying UNLESS of course you add more code.
I like to use Custom Components to compartmentalize my code so that the approach up there is easy.
If user has ANY of these Roles (Fitler/Lookup) CountRows() > 0
then every function is valid for them to run..
If not set a custom property to NoPermission or something.
This way you aren't constantly guessing 🙂
One approach or the other is what you have for options.
If I have helped you, I would really appreciate if you please Mark my answer as Resolved/Answered, and give it a thumbs up, so it can help others
Cheers
Thank You
Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
https://gernaeysoftware.com
LinkedIn: https://www.linkedin.com/in/michaelgernaey