OverRide JumpRef method in standard form cotrol in D365FO.
- Copy Form 'OnInitialized' Event handler from standard form.
[FormEventHandler(formStr(SMAParameters), FormEventType::Initialized)] public static void SMAParameters_OnInitialized(xFormRun sender, FormEventArgs e) { var overrides = new TestClass(); FormStringControl formControl = sender.design().controlName(formControlStr(SMAParameters, FormControlName)); formControl.registerOverrideMethod(methodStr(FormStringControl, jumpRef), methodStr(TestClass, MethodName), overrides); }
- In TestClass I have created a new method and written the below code.
public void method(FormControl _formControl)
{
// With Filter
FormRun formRun;
Args args = new Args();
FormDataSource formDataSource = new FormDataSource();
args.name(formStr(formName));
formRun = ClassFactory.formRunClass(args);
formRun.init();
formDataSource = formRun.dataSource();
formRun.run();
formDataSource.filter(fieldNum(TableName, FieldName), "Value");
formRun.detach();
----------------------------------------------------------------------------------
// With out Filter
Args args = new Args();
args.record(common);
new MenuFunction(menuitemdisplaystr(menu item name),
MenuItemType::Display).run(args);
--------------------or------------------------------------------
smmUtility::openMenuItemForm(menuitemDisplayStr(My menu item name), null, _formControl);
}
Normal jumpref:
public void jumpRef(FormControl _formControl) { smmUtility::openMenuItemForm(menuitemDisplayStr(My menu item name), null, this); -----------------------or----------------------------------------------- new MenuFunction(menuitemdisplaystr(menu item name), MenuItemType::Display).run(args); }
Keep Daxing!!
No comments:
Post a Comment