HOW TO CREATE INIT VALUE EVENT HANDLER IN D365 AT TABLE LEVEL
In Table Datasource Events > right click on Init Value > Copy Post/Pre Event Handlers
Table Method Event Handler
EXAMPLE
class test SalesTableEventHanlders
//you can give any name ....or else you can decorate the class with extensionof(tablestr(salestable));
//in that case you would be able to get the fields directly using this keyword.
//shown at bottom
{
There are a few rules for augmentation classes:
- They must be final.
- They must be suffixed by _Extension.
- They must be decorated with the [ExtensionOf()] attribute.
Table Method Event Handler
EXAMPLE
class test SalesTableEventHanlders
//you can give any name ....or else you can decorate the class with extensionof(tablestr(salestable));
//in that case you would be able to get the fields directly using this keyword.
//shown at bottom
{
/// <summary>
///
/// </summary>
/// <param name="args"></param>
[PostHandlerFor(tableStr(SalesTable), tableMethodStr(SalesTable, initValue))]
public static void SalesTable_Post_initValue(XppPrePostArgs args)
{
SalesTable SalesTable = args.getThis() as SalesTable;
SalesTable.isclosed =NoYes::Yes;
}
}
///
/// </summary>
/// <param name="args"></param>
[PostHandlerFor(tableStr(SalesTable), tableMethodStr(SalesTable, initValue))]
public static void SalesTable_Post_initValue(XppPrePostArgs args)
{
SalesTable SalesTable = args.getThis() as SalesTable;
SalesTable.isclosed =NoYes::Yes;
}
}
[ExtensionOf(tableStr(InventTable))]
final class InventTable_Extension
{
public void myDefaultInventLocationId()
{
// This would have partner specific logic to initialize the new field.
this.MyInventLocationId = this.inventLocationId();
}
}
Thanks,
Vikas Mehta
No comments:
Post a Comment