Hi Folks,
Let’s see how to write a new method on standard application object using the extension framework. An extension enables you to add functionality to existing model elements and source code.
Before starting adding new method, you need to create a new extension class for your object and this class should be declared as final and post fixed by ‘Extension’ keyword. See below example,
For Table:
[ExtensionOf(tableStr(CustTable))]
final class MyCustTable_Extension
{
<new methods>
}
For Class:
[ExtensionOf(classStr(CustExchAdj))]
final class MyCustExchAdj_Extension
{
<new methods>
}
For Form:
[ExtensionOf(formStr(VendParameters))]
final class MyVendParameters _Extension
{
<new methods>
}
Now lets see how to add different types of methods
1. New edit method
For Extension methods, the first argument in method parameter must be the object you're extending e.g. table buffer. See below code for reference;
public static edit str60 MyFieldEdit(<tableName> _this, boolean _set, name value)
{
MyTable mytable = <tablename>;
if(_set)
{
if(value)
{
ttsbegin;
custTable = CustTable::find(<tablename>.CustAccount,true);
custTable.Name = value;
custTable.update();
ttscommit;
}
}
}
2. New display method
public static display EcoResDescription productName(InventSum _this)
{
Return _this.itemName();
}
3. Normal method
In the same way, you can write a new method, this method also needs to be static so it can be accessed on the form.
Public static updateSearchName(_this, Name _newName)
{
Mytable mytable = _this;
If(_newname)
{
Ttsbegin;
Mytable.searchName = _ newname;
MyTable.update();
Ttscommit;
}
}
Edit method on table extension or new methods on table extension, all method needs to be static. Now to access these methods, go to your form and add new field type of string/real/XYZ. Set below property
Cheers,
Harry
Search This Blog
August 12, 2018
August 03, 2018
Change a person on User in Dynamics 365 FO
Hi Folks,
Recently I uploaded my first video on youtube regarding a basic thing, I hope you will like it.
-Harry Follow us on Facebook to keep in rhythm with us. @Facebook
Recently I uploaded my first video on youtube regarding a basic thing, I hope you will like it.
-Harry Follow us on Facebook to keep in rhythm with us. @Facebook
Subscribe to:
Posts (Atom)