web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How do i give create permisson on programatically in c# for a custom entity?

(0) ShareShare
ReportReport
Posted on by 106

How do i give create permisson on programatically in c# for a custom entity?

*This post is locked for comments

I have the same question (0)
  • Abby Kong Profile Picture
    6 on at

    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

  • Suggested answer
    Priyesh Profile Picture
    7,396 User Group Leader on at

    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.

  • Raghav Chadha Profile Picture
    106 on at

    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?

  • Abby Kong Profile Picture
    6 on at

    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

  • Suggested answer
    Dynamics365 Rocker Profile Picture
    7,755 on at

    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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans