Showing posts with label Extensions. Show all posts
Showing posts with label Extensions. Show all posts

Friday, September 27, 2019

D365 Finance & Operation - Sample customization using ExtensionOf


Sample customization in D365 using Visual Studio, ExtensionOf attribute for beginners.

Note : I used VHD so I'm skipping LCS part.

Step 1: Open Visual studio as Admin

Step 2 : Create model



 
Step 3 : Select "Create new package"

Step 4 : I selected ApplicationPlatform, ApplicationSuite,ApplicationFoundation and Retail packges. You can select whatever you want based on your requirement.

Step 5 : Create new Unified Operations project
                                   

Step 6 : Create new class

                                   


Step 7 : Add following code, I added info log in run() to display the sales order id, by extending SalesTable form and build the project.

[ExtensionOf(formStr(SalesTable))]
final class SalesTable_Extension
{
void run()
    {
        next run();
        info ("Sales Order "+SalesTable.salesId);
    }

}

Step 8 : To test the code, open the F&O and go to Sales order and select any Sales id.



That's it.

Happy Daxing,

Regards,
Arun S. Keerthi



 

Wednesday, February 1, 2017

AX 7 Using Extensions

In AX 7  X++ supports extension methods similarly to C#, it really helps develop better without modify base objects.

We can create table/class methods without touching respective object.


Step 1 : Create a final class with Prefix of _extension

Step 2 : Add attribute mentioning Extensionof  for tablestr and mention table name

Step 3 : Add Public method to handle business logic

Step 4 : Call the method in required place



Sample Class to Handle DirPersonName table fullname method

[ExtensionOf(tableStr(DirPersonName))]
final class MyDirPersonName_Extension
{
    public PersonName fullName()
    {
        return strFmt('%1 %2 %3'this.FirstName, this.MiddleName, this.LastName);
    }
}

You can call above method in your program

while select dirPersonName
{
    info(dirPersonName.fullName());
}
source : https://blogs.msdn.microsoft.com/mfp/2015/12/15/x-in-ax7-extension-methods/