Fields Disable (Read Only) in Editable Grid in Dynamics 365
```htmlFields Disable (Read Only) in Editable Grid in Dynamics 365
Editable Grids are one of the most useful features in Dynamics 365 because they allow users to update records directly from views and subgrids without opening individual forms.
However, there are many business scenarios where certain fields should remain read-only while still allowing users to edit other columns.
In this article, we will learn how to disable specific fields in Editable Grids using JavaScript and Field Security Profiles in Dynamics 365.
What is an Editable Grid?
Editable Grids allow users to perform inline editing directly within:
- Main Grids
- Subgrids
- Associated Views
- Related Records
Instead of opening each record individually, users can update data directly from the grid.
Dynamics 365 supports rich inline editing through Editable Grid controls.
Business Requirement
Suppose you have the following grid:
Customer Name Email Address Phone Number Status
Requirement:
Customer Name = Editable Phone Number = Editable Status = Editable Email Address = Read Only
Users should not be able to modify Email Address from the Editable Grid.
Why Disable Fields?
Common scenarios include:
Approval Process
Lock approved information.
Financial Data
Prevent editing of calculated values.
Customer Records
Protect important contact details.
Compliance Requirements
Restrict sensitive fields.
Audit Control
Prevent unauthorized changes.
Available Approaches
There are two common approaches:
Field Security Profile
and
JavaScript
Both methods are widely used in Dynamics 365 implementations.
Field-level security and JavaScript event handling are common approaches for controlling editable grid behavior.
Method 1: Using Field Security Profile
This is Microsoft's recommended security-based approach.
Step 1: Enable Field Security
Navigate to:
Table ↓ Columns ↓ Select Column ↓ Enable Field Security
Example:
Email Address
Step 2: Create Field Security Profile
Navigate:
Advanced Settings ↓ Security ↓ Field Security Profiles
Create:
Read Only Email Profile
Step 3: Configure Permissions
Set:
Read = Yes Create = Yes Update = No
Result:
Email Field ↓ Read Only
Users can view but cannot modify the field.
Field Security Profiles can prevent updates while still allowing read access.
Method 2: Using JavaScript
JavaScript provides more flexibility for business scenarios.
Editable Grids support JavaScript events such as OnRecordSelect and OnChange.
Step 1: Create JavaScript Web Resource
Example:
new_EditableGrid.js
Upload to Dynamics 365.
Step 2: Add Function
function onGridRowSelected(context)
{
context
.getFormContext()
.getData()
.getEntity()
.attributes.forEach(function(attr)
{
if(attr.getName() === "emailaddress1")
{
attr.controls.forEach(function(ctrl)
{
ctrl.setDisabled(true);
});
}
});
}
This approach disables the Email Address field whenever a row is selected in the editable grid.
Step 3: Register Event
Navigate:
Editable Grid Control ↓ Events ↓ OnRecordSelect
Register:
onGridRowSelected
Pass:
Execution Context
How It Works
User Selects Row ↓ OnRecordSelect Event ↓ JavaScript Executes ↓ Email Field Disabled ↓ Read Only Experience
Editable grid controls evaluate events when a row becomes active for editing.
Disable Multiple Fields
Example:
function lockFields(context)
{
context
.getFormContext()
.getData()
.getEntity()
.attributes.forEach(function(attr)
{
var fields =
[
"emailaddress1",
"telephone1",
"jobtitle"
];
if(fields.indexOf(attr.getName()) > -1)
{
attr.controls.forEach(function(ctrl)
{
ctrl.setDisabled(true);
});
}
});
}
Result:
Email = Read Only Phone = Read Only Job Title = Read Only
Disable Based on Condition
Requirement:
Status = Approved
Then:
Email Address Phone Number Job Title
become read-only.
Example:
function lockApprovedRecords(context)
{
var formContext =
context.getFormContext();
var status =
formContext.getAttribute("statuscode")
.getValue();
if(status == 100000001)
{
formContext
.getControl("emailaddress1")
.setDisabled(true);
}
}
Make Entire Editable Grid Read Only
Sometimes the entire grid must become read-only.
Workflow:
User Opens Grid ↓ Select Row ↓ All Fields Disabled
Example:
function makeGridReadOnly(context)
{
var entity =
context
.getFormContext()
.data
.entity;
entity.attributes.forEach(function(attribute)
{
attribute.controls.forEach(function(ctrl)
{
ctrl.setDisabled(true);
});
});
}
This pattern is commonly used to create read-only editable grid experiences.
Common Editable Grid Events
OnRecordSelect
Triggered when a row is selected.
OnChange
Triggered when a value changes.
OnSave
Triggered before record save.
Editable Grids support these JavaScript events for customization.
Real-World Example
Opportunity Management
Editable Grid:
Opportunity Name Estimated Revenue Probability Status
Requirement:
Status = Won
Then:
Estimated Revenue Probability
become read-only.
Workflow:
Opportunity Won ↓ User Selects Record ↓ JavaScript Executes ↓ Fields Locked
This prevents accidental modifications after closure.
Limitations
Editable Grids do not automatically honor fields that are merely set as read-only on forms.
Additional approaches such as Field Security Profiles, Entity-scoped Business Rules, or JavaScript are often required.
Some considerations:
- OnRecordSelect must be configured.
- JavaScript executes only after row selection.
- Power Apps Grid behaves differently in some scenarios.
- Field Security remains the most secure approach.
Best Practices
- Use Field Security for sensitive data.
- Use JavaScript for dynamic requirements.
- Test across browsers.
- Use OnRecordSelect event.
- Keep logic reusable.
- Document customizations.
Benefits
- Better Data Integrity – Protect important fields.
- Improved User Experience – Users clearly know what can be edited.
- Reduced Errors – Prevent accidental updates.
- Flexible Customization – Support complex business rules.
- Better Security – Protect critical business data.
Common Use Cases
- Opportunity Management
- Customer Records
- HR Systems
- Project Management
- Service Management
Conclusion
Editable Grids provide powerful inline editing capabilities in Dynamics 365, but not every field should remain editable.
By using Field Security Profiles and JavaScript with the OnRecordSelect event, organizations can control which fields remain read-only while still benefiting from the productivity of inline editing.
Whether you're working with Opportunities, Accounts, Contacts, Projects, or custom Dataverse tables, implementing read-only columns in Editable Grids improves data quality, security, and user experience.
```