I have a form that contain two same fields 'Nama Mentor PIC' with logical name 'ecom_namamentor'
I want to lock them using javascript, but when I run the application only 1 field is locked while the others are not.
even though both fields have the same logical name, and in javascript I have set it to be locked but it doesn't work.
how can i lock those two fields? Did I miss something?
this is javascript code
and this is what the form field looks like when javascript is run
Please use the below and remember to pass executionContext as the first Parameter when registering the event
var formContext = executionContext.getFormContext();
var attr = formContext.getAttribute("ecom_namamentor");
attr.controls.forEach(function (control) {
control.setDisabled(true);
});
Hi @DewiCR,
To supplement on @Mira_Ghaly post, the controls.get gets the first control but since you have more than 1 on the form that's why you would have to loop through each one as per the sample code. And Xrm.Page is deprecated so this is why the code uses formContext. Hope her post helps!