Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Unanswered

How disable a field in a main editable grid with a condition do to that?

Posted on by 10
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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans