Disable grid field based on other field value in D365 FO
Here we will see how we can disable field in the grid based on the other field value.
1. Create a call extension for the form
2. Goto From the data source and in events copay active event
3. come to class you created in step one and past it.
4. Below is the sample code.
[ExtensionOf(formStr(FormParameters))]
final class ParametersFormUP_Extension
{
///
/// for UsagePrice the Group should must be disabled
///
///
[FormDataSourceEventHandler(formDataSourceStr(FormParameters,FormDatasource), FormDataSourceEventType::Activated)]
public static void FormDatasource_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
{
FormDataSource fds = sender.formRun().dataSource(formDataSourceStr(FormParameters,FormDatasource));
FormDatasourceTable dsTable = fds.cursor();
FormRun fr = sender.formRun();
//FormControl fc = fr.design(0).controlName("FINMeters_FINRollover");
//FormControl fcMeterType = fr.design(0).controlName("FINMeters_FINMeterType");
//fc.enabled(meterTable.FINMeterType == FINMeterType::Continuous);
fds.object(fieldNum(FormDatasourceTable ,fieldForGroup)).allowEdit(!(dsTable.AgreementType == AgreementType::UsagePricing));
}
}
No comments:
Post a Comment