Here Im using CustGroup Form To Perform Some Operations By using FormEventHandlers.
1.Using On Intilizing EventHandler To disable a Control In CustGroup form.
Here the Code snippet....
2.Using On clicked EventHandler For a Button
[FormControlEventHandler(formControlStr(CustGroup, Clicked), FormControlEventType::Clicked)]
public static void Clicked_OnClicked(FormControl sender, FormControlEventArgs e)
{
// FormRun formRun = sender.formRun() as FormRun;
CustGroup custGroup;
custGroup = sender.formRun().dataSource().cursor(); // to get current activated Record
info(strFmt('%1 - %2 ',custGroup.CustGroup,custGroup.Name));
}
3. Using onInitilized event handler to disable a button
[formeventhandler(formstr(custgroup), formeventtype::initialized)]
public static void custgroup_oninitialized(xformrun sender, formeventargs e)
{
custgroup custgroup;
formdatasource ds = sender.datasource(formdatasourcestr(custgroup, custgroup)); //current datasource
sender.design().controlname(formcontrolstr(custgroup,clicked)).enabled(false);
custgroup = ds.cursor();
info(custgroup.custgroup);
}
3. Using onActivated event handler
[formdatasourceeventhandler(formdatasourcestr(Custgroup, Custgroup), formdatasourceeventtype::activated)]
public static void custgroup_onactivated(formdatasource sender, formdatasourceeventargs e)
{
Custgroup custgroup;
// formdatasource ds = sender.datasource(formdatasourcestr(custgroup, custgroup));
FormRun formRun = sender.formRun() as FormRun;
custgroup = sender.cursor();
formRun.design().controlName(formControlStr(Custgroup,Clicked)).enabled(custgroup.CustGroup <='30');
//if(custgroup.CustGroup <='30')
//{
// formRun.design().controlName(formControlStr(Custgroup,Clicked)).enabled(false);
//}
//else
//{
// formRun.design().controlName(formControlStr(Custgroup,Clicked)).enabled(true);
//}
// info(strfmt('%1 - %2 ',custgroup.custgroup,custgroup.name));
}