function lockSubgridFields(executionContext) {
    debugger;
    let oFormContext = executionContext.getFormContext();
    if (oFormContext) {
        let arrFields = ["nparks_testcode", "nparks_labresultoutcome"];
        let objEntity = oFormContext.data.entity;
        if (objEntity && objEntity.getEntityName()) {
            objEntity.attributes.forEach(function (attribute, i) {
                if (arrFields.indexOf(attribute.getName()) > -1) {
                    let attributeToDisable = attribute.controls.get(0);
                    attributeToDisable.setDisabled(true);
                }
            });
        } else {
            console.error('Entity data not loaded.');
        }
    }
}
 
I have used the above code but I am getting the below issue
 
TypeError: Cannot read properties of undefined (reading 'entity')