Hello guys.
I have an main editable grid outside of a form that contains several month fields. The rule is for example: if the field abi_month == august (8) has to block for editing the corresponding fields from previous months (abi_january, abi_february, etc)
I'm using these functions, debugging it is working, but it does not block the fields. Can someone help me?
onRecordSelect: function (executionContext) {
var _formContext = executionContext.getFormContext();
var disableFields = ["abi_january", "abi_january_prepaid"];
Abi.App360.LElines.lockFields(executionContext, disableFields);
},
lockFields: async function (executionContext, disableFields) {
var formContext = executionContext.getFormContext();
var currentEntity = formContext.data.entity;
var currentMonth = null
var id = formContext.data.entity.getId();
// var filter = "?$select=abi_month,abi_january,abi_february,abi_march,abi_april,abi_may,abi_june,abi_july,abi_august,abi_september,abi_october,abi_november,abi_december,abi_january_prepaid,abi_february_prepaid,abi_march_prepaid,abi_april_prepaid,abi_may_prepaid,abi_june_prepaid,abi_july_prepaid,abi_august_prepaid,abi_september_prepaid,abi_october_prepaid,abi_november_prepaid,abi_december_prepaid";
await Xrm.WebApi.retrieveRecord("abi_le", id.replace("{", "").replace("}", "")).then(
function success(result) {
currentMonth = result["abi_month"]
}
)
if (currentMonth == 3) {
currentEntity.attributes.forEach(function (attribute, i) {
if (disableFields.indexOf(attribute.getName()) > -1) {
var attributeToDisable = attribute.controls.get(0);
attributeToDisable.setDisabled(true);
}
});
}
}
*OBS :
As it is a main grid, there is some way to get its context, I don't know.
Thans