Skip to main content

Notifications

Announcements

No record found.

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

  • Suggested answer
    Dynamics365 Rocker Profile Picture
    7,755 on at
    RE: How do i give create permisson on programatically in c# for a custom entity?

    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.

  • Abby Kong Profile Picture
    6 on at
    RE: How do i give create permisson on programatically in c# for a custom entity?

    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

  • Raghav Chadha Profile Picture
    106 on at
    RE: How do i give create permisson on programatically in c# for a custom entity?

    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?

  • Suggested answer
    Priyesh Profile Picture
    7,396 User Group Leader on at
    RE: How do i give create permisson on programatically in c# for a custom entity?

    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.

  • Abby Kong Profile Picture
    6 on at
    RE: How do i give create permisson on programatically in c# for a custom entity?

    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

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 52

#3
Victor Onyebuchi Profile Picture

Victor Onyebuchi 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans