Showing posts with label HOW TO CREATE INIT VALUE EVENT HANDLER IN D365 AT TABLE LEVEL. Show all posts
Showing posts with label HOW TO CREATE INIT VALUE EVENT HANDLER IN D365 AT TABLE LEVEL. Show all posts

Friday, 8 February 2019

TABLE INIT VALUE IN D365 EVENT HANDLER DATASOURCE tABLE_Post/PRE_initValue

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
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.
Create new Class and below code

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;
    }
}


[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

Blog Post 6: Bonus – Building Your First Custom Copilot Plugin in X++

Blog Post 6: Bonus – Building Your First Custom Copilot Plugin in X++  Introduction In our previous posts, we explored what Copilot can do o...