Reputation: 177
I am trying to disable a date field(by selecting date) in the Dynamics365 CRM UCI version. It is disabling it but on selecting the date twice. It is working fine in a classical mode but not on UCI
here is my code.
function ConfirmFunction(){
debugger;
var get_aob_date = Xrm.Page.ui.controls.get("ies_aobdatercvd");
var confirmStrings = { text:"This is a confirmation.", title:"Confirmation Dialog" };
var confirmOptions = { height: 200, width: 450 };
Xrm.Navigation.openConfirmDialog(confirmStrings, confirmOptions).then(
function (success) {
if (success.confirmed)
get_aob_date.setDisabled(true);
else
Xrm.Page.getAttribute("ies_aobdatercvd").setValue();
});
}
Upvotes: 0
Views: 2718
Reputation: 116
Is this in a custom web resource?
The use of Xrm.Page is deprecated for everything other than custom web resources(currently) and should be replaced with the execution context.
Here is what your code should look like to disable your field:
function DisableDate(executionContext){
var formcontext = executionContext.getFormContext();
formcontext.getControl("ies_aobdatercvd").setDisabled(true);
}
When you add the event to the onLoad (or any other event) you'll need to check the "Pass execution context" checkbox:
Upvotes: 2