Editable Grid:

In this blog we will show disable fields based on some conditions on Editable grid views. To disable fields on Editable Grid views, We can write javascript code on OnRecordSelect event handler of Editable Grid.

Add below code to your webresource by changing or adding disable fields in the code

function onRecordSelect(executionContext) {
  var formContext = executionContext.getFormContext();
  var disableFields = [“vinay_cost1”];
  lockFields(executionContext, disableFields);
}

function lockFields(executionContext, disableFields) {
  var formContext = executionContext.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);
    }
  });
}

Next, add the event handler on onrecordselect
Editable Grid

Next, Save and Publish the form

Now we can see the field is locked when we select record on editable grid.

For any Help or Queries Contact us on info@crmonce.com or +918096556344