How to Enable/Disable a field on the form by event handler method in Dynamics(D365). #dynamics #d365 #ax
Here we have an OnModified event handler of RecordPriorToRAF form control(or we can say field). Now I'm going to enable and disable another form control
according to my requirement.
[FormControlEventHandler(formControlStr(PdsBatchAttrib, PdsBatchAttrib_RecordPriorToRAF), FormControlEventType::Modified)]
public static void PdsBatchAttrib_RecordPriorToRAF_OnModified(FormControl sender, FormControlEventArgs e)
{
// Get DataSource
PdsBatchAttrib batchAttrib = sender.formRun().dataSource(formdatasourcestr(PdsBatchAttrib, PdsBatchAttrib)).cursor() as PdsBatchAttrib;
if(Condition...)
{
// Disable MandatoryPriorToRAF field
sender.formRun().design().controlName(formControlStr(PdsBatchAttrib, PdsBatchAttrib_MandatoryPriorToRAF)).enabled(false);
}
else
{
// Enable MandatoryPriorToRAF field
sender.formRun().design().controlName(formControlStr(PdsBatchAttrib, PdsBatchAttrib_MandatoryPriorToRAF)).enabled(true);
}
}
}

Like
Report
*This post is locked for comments