Announcements
Dear all,
Can you please let me know how to call method on Standard Form OR form - DS methods in standard form?
Please give me more she'd on this
Thanks!
Yes new methods you have to add in extension . In above case you are able to achieve your requirement using event handler , which can be implemented by creating simple class.
Thanks bro,
That means when i wants to add new method in Standard form then it should be always done by "ExtensionOf " only.
The above code which i did i think "ExtensionOf " is NOT required for this because i am going to visible False of control only not going to add any new method.
is't correct?
You can use ExtensionOf with Chain of Command to wrap the init method of the form and achieve the same result as you did with your event handler.
Event handlers existed in D365FO (and AX) already before Chain of Command was introduced. And still there are scenarios where event handlers are the only solution. But there is a big overlap in what you can achieve with event handlers and CoC. The benefit of CoC is that you can access protected variables, enhance protected methods and include your code in the same transaction scope as the standard code. There's also better compile time check for your code, and it's easier to read and write.
In addition to CoC, class augmentation (ExtensionOf) can also be used to add completely new methods to standard objects.
Extension of is used when you want to create extension of object. You did right thing by not mixing event handler implementation in extension class. When you want to add suppose any method on the form then you are going to create extension class for that form and add method in that, same thing applies to tables classes etc.
Hi All,
I am creating a New class like "CustTableEventHandler".
Then i will go CustTable form > Events >OnInitialized > CopyEventHandlerMethod
Class CustTableEventHHandler
{
I follow the below link
https://blogs.msdn.microsoft.com/mfp/2018/12/05/chain-of-command-on-forms/
When i will use "ExtensionOf..." ?
Please give me more shed on this.
Thanks!
Good explanation
If you have the FormRun in a variable, you can call your methods on the form.
1. Add this method in your form (using "ExtensionOf" augmentation, if it's a standard form):
public FormDataSource getMyDataSource() { return MyTable_ds(); }
2. Call the methods of formRun:
myFormRun.myMethod(); // This calls method "myMethod" in your form FormDataSource myDataSource = myFormRun.getMyDataSource(); myDataSource.refresh(); // This calls method refresh of your form data source
Call any method of caller form into a class or any other form
Requirement
Here is very impressive piece of code for calling any method of custom or base form in a class or any form.
In standard form “PurchCreateFromSalesOrder” there is a base method specifyVendAccount which i need to call on extension class of form “PurchCreateFromSalesOrder” on the modification of a new custom control i have created separately on the same form “PurchCreateFromSalesOrder“.
Sample Code With Explanation
I created one class and a new event method.
[FormControlEventHandler(formControlStr(PurchCreateFromSalesOrder, FormStringControl1), FormControlEventType::Modified)]
public static void FormStringControl1_OnModified(FormControl sender, FormControlEventArgs e)
{
FormRun formRun =sender.formRun();
SalesLine salesLine;
FormDataSource formDataSource;
Object formRunObject;
;
salesLine = SalesLine::findRecId(68719716393);
formRunObject = formRun.dataSource(1);
formRunObject.specifyVendAccount(true, SalesLine, ‘INMF-000001’); //here i am calling the method of form datasource
formRun.dataSource(1).write();
formRun.dataSource(1).research(true);
formRun.dataSource(1).refresh();
}
you csn use COC for forms and it's datasource.
André Arnaud de Cal...
294,095
Super User 2025 Season 1
Martin Dráb
232,866
Most Valuable Professional
nmaenpaa
101,158
Moderator