How do i give create permisson on programatically in c# for a custom entity?
*This post is locked for comments
How do i give create permisson on programatically in c# for a custom entity?
*This post is locked for comments
Do you want to update Security role?
Please clarify if you need to give create privilege for a record only.
You can also use access team and add member in that access team to give read access for a specific record.
Hi Raghav,
I gave it a try myself. AddPrivilegesRoleRequest does work with custom entities, not just OOB entities.
------------------------------
The challenge is to find the PrivilegeId, there are a few ways to find it. If you are using on-prem dynamics, you can find them in the database.
If you are using online, there is a little trick:
1. Find instance web API URL (this can be found in Developer Resources), and append /privileges?$select=name
2. Search in the result from the URL from step1 for the privilege id (e.g. if your custom entity is new_test, and you want to find the create privilege: search for prvCreatenew_test)
------------------------------
The code would be something like this:
var addPrivilegesRequest = new AddPrivilegesRoleRequest { RoleId = roleId, Privileges = new[] { new RolePrivilege { PrivilegeId = prvCreatenew_test, Depth = PrivilegeDepth.Basic } } }; svc.Execute(addPrivilegesRequest);
Regards,
Abby
How to give privilege to custom entity addprivelegerolerequest is giving for OOTB i think,Can you provide any code for custom entity security roles privilege change?
Hi,
Programmatically you can use GrantAccess and RevokeAccess messages. Check this -
docs.microsoft.com/.../sample-share-records-using-grantaccess-modifyaccess-revokeaccess-messages
Hope this helps.
Hi Raghav,
AddPrivilegesRoleRequest and AddMembersTeamRequest under Microsoft.CRM.SDK.Messages might help.
AddPrivilegesRoleRequest is to add an existing privilege to an existing role.
AddMembersTeamRequest is to add an existing user to an existing team, thus make the security roles applied for the team to start applying for the user.
docs.microsoft.com/.../microsoft.crm.sdk.messages.addprivilegesrolerequest
Regards,
Abby
Mohamed Amine Mahmoudi
83
Super User 2025 Season 1
Community Member
52
Victor Onyebuchi
6