web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

DisplayMethod recap in Microsoft Dynamics 365 Finance and Operations apps

Rahul Mohta Profile Picture Rahul Mohta 21,032

DisplayMethod recap in Microsoft Dynamics 365 Finance and Operations apps

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.

 

From <https://docs.microsoft.com/en-us/dynamics365/unified-operations/dev-itpro/extensibility/add-method-table>

 

[ExtensionOf(tableStr(InventTable))]

final class MyInventTable_Extension

{

    [DataEventHandler(tableStr(InventTable), DataEventType::Inserting)]

    public static void InventTable_onInserting(Common sender, DataEventArgs e)

    {

        InventTable inventTable = sender as InventTable;

        // Call the method as if it was defined directly on InventTable.

        inventTable.defaultMyInventLocationId();

    }

    public void defaultMyInventLocationId()

    {

        // This would have partner specific logic to initialize the new field.

        this.MyInventLocationId = this.inventLocationId();

    }

}

can do that via class extension

for example:: we need to view vendor group name for the vendor in vendtable form  

1-Create a new class and name it as <Classname>_<Extension>

so you can create this class with the below syntax 

 

public static class Vendtable_Extension

{

}

Note:: the suffix (_Extension) is a must 

2-Create the display methods in the class 

public static class Vendtable_Extension

{

[SysClientCacheDataMethodAttribute(true)]  //This attribute will cache your display method.

public static display Name VendGroupName(Vendtable _this)

{

return vendgroup::find(_this.vendgroup).name;

}

}

Comments

*This post is locked for comments