Thanks in Advance, Can anyone help me on how to make the default public view of an entity as read only or restrict the user to edit any column in that view. If I select any record all the column are shown as locked except the highlighted columns. Is there a way to lock the those columns in the view or to make the whole view as read only.
Hi there! Good morning, evening, or afternoon - depending on where you are :) Hope you are well today!
To make the default view of an entity read-only in Dynamics 365, you can achieve this by leveraging field-level security or custom JavaScript. Here's how you can approach this: 1. Field-Level Security
Use field-level security to restrict editing of specific fields in the entity:
Navigate to Settings > Security > Field Security Profiles.
Create a new profile or edit an existing one.
Add the fields you want to lock and set their permissions to Read-only for the relevant users or teams.
This ensures that users can view the fields but cannot edit them, even in the default view.
2. Custom JavaScript
Add JavaScript to the entity form to dynamically lock fields based on the view:
Navigate to Settings > Customizations > Customize the System.
Open the entity form and add a JavaScript web resource.
Use the following code snippet to lock fields: function lockFields(executionContext) { var formContext = executionContext.getFormContext(); var fieldsToLock = ["field1", "field2"]; // Replace with actual field names
fieldsToLock.forEach(function(field) { var attribute = formContext.getAttribute(field); if (attribute) { attribute.controls.forEach(function(control) { control.setDisabled(true); }); } }); }
Register the script on the form's OnLoad event.
3. Use a Custom View
Create a custom view that displays the required fields but restricts editing:
Navigate to Settings > Customizations > Views.
Create or edit the default view for the entity.
Configure the view to display only the fields you want users to see.
While this doesn't lock the fields, it limits what users can interact with.
4. Role-Based Security
Use role-based security to restrict editing permissions for the entity:
Navigate to Settings > Security > Security Roles.
Edit the relevant role and set the entity's permissions to Read-only.
5. Test the Configuration
After implementing the changes, test the default view to ensure that the fields are locked and users cannot edit them.
Was this reply helpful?YesNo
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.