Edit/Display or new methods on standard application objects [#Dyn365FO]

Hi Folks,
Let’s see how to write new method on standard application object using 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 need to be static so it can be access on 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 need to be static. Now to access these methods, go to your form and Add new field type of string/real/xyz. Set below property
clip_image002

Cheers,
Harry


















































No comments:

Post a Comment

Thanks