FormDataSourceEventType::Activated in d365
WRITE THE BELOW CODE IN NEW CLASS OR ANY OTHER CLASS.
MAKE SURE THAT YOU USE THE METHOD SIGNATURE PROPERLY.EXAMPLE
class CustTableFormEventHandler
{
[FormDataSourceEventHandler(formDataSourceStr(CustTable, CustTable), FormDataSourceEventType::Activated)]
public static void CustTable_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
{
CustTable custTable = sender.cursor(); //selected record
FormDataSource custTable_ds = sender.formRun().dataSource("CustTable"); //DataSource
FormRun element = sender.formRun(); //form element
FormControl myNewButton = element.design(0).controlName("MyNewButton");
//button on the form
myNewButton.enabled(false); // enabled or disabled the button
}
}
another example
[FormDataSourceEventHandler(formDataSourceStr(HRMCompFixedEmpl, HRMCompFixedEmpl), FormDataSourceEventType::Activated)]
public static void HRMCompFixedEmpl_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
{
HRMCompFixedEmpl compFixedEmpl = sender.cursor();
FormDataSource hrmCompFixedEmpl_ds = sender.formRun().dataSource(“HRMCompFixedEmpl”);
FormRun element = sender.formRun();
FormControl control1= element.design(0).controlName(“HRMCompFixedEmpl_field”);
if(compFixedEmpl.Status == NoYes::Yes)
{
control1.enabled(true);
}
else
{
control1.enabled(false);
}
}
Thanks,
Vikas Mehta
Vikas Mehta
No comments:
Post a Comment