asolovyov
asolovyov

Reputation: 963

How to restrict access to specific item in entity list in MS Dynamics CRM

I have several custom entities. There are two users: user1 and user2.

For one entity type I have 2 items in the list.

I need to show only one item for user1 and only second for user2.

I tried to manage permissions via share dialog, but it can only restrict write permission, but I need to hide item from the list views.

How can I do that?

Upvotes: 0

Views: 639

Answers (2)

Payam Zare
Payam Zare

Reputation: 103

you can do this function with two Solution.

Solution 1: Use Field Security Profile, in this solution you have to enable field security option in field Customization , and then go to Customization > customize the system > field Security Profile, then you can see your field that enabled field security option in last session, and then Click on new button and select User 1 and select the permission option what you want between read Update Create for field1 and same as this for field 2 and user 2. (Notice : this option only work when users haven't Administrator Security Role.)

Solution 2: You can Use Javascript and Handle this action Client Side. first you must go to form Customization and add new Library and add this Code.

function onload() 
{
    checkUser(); 
}  

function checkUser() 
{
    var userID = Xrm.Page.context.getUserId();
    if( userID == "user1 id")
    {
        Xrm.Page.getControl("field1").setVisible(true);
        Xrm.Page.getControl("field2").setVisible(false);
    }
    else if( userID == "user2 id")
    {
        Xrm.Page.getControl("field1").setVisible(false);
        Xrm.Page.getControl("field2").setVisible(true);
    }
}

and then in form on load event call the onload function and over and all things is great :)

I hope your problem solved :)

Upvotes: 1

Henrik H
Henrik H

Reputation: 5787

The CRM security model limits access to records using Security Roles. You can set up your custom entities with the privilege of Local Read, which only gives users access to read records they own.

User1 would then own Record1, while User2 would own Record2.

Alternatively, you could also look into having a hierarchy of Business Units, which also segments visibility of data.

Have a look at How role-based security can be used to control access to entities in Microsoft Dynamics CRM and The security model of Microsoft Dynamics CRM for more information.

Upvotes: 2

Related Questions