How to lock field using javascript Dynamic CRM 365 | How to read-only fields using custom Javascript
function onRecordSelect(exeContext) {
var _formContext = exeContext.getFormContext();
//add fields schema name you want to disable fields
var disableFields = ["vwi_name","vwi_paymentcode","vwi_claimid","vwi_totalpaymentamount"];
lockFields(exeContext, disableFields);
}
//Function
function lockFields(exeContext, disableFields) {
var _formContext = exeContext.getFormContext();
var currentEntity = _formContext.data.entity;
currentEntity.attributes.forEach(function (attribute, i) {
if (disableFields.indexOf(attribute.getName()) > -1) {
var attributeToDisable = attribute.controls.get(0);
attributeToDisable.setDisabled(true);
}
});
}