Tuesday, June 25, 2019

Add methods to tables through extension

Creating table extension does not allow you to add new methods.
As you can see in the screenshot below.
When i right clicked on Methods node of table extension there is no option available to add
" New Method ".




So to add a new method in standard table we need to follow the following steps.
  1. Create an Extension class for table
    Right click on your project then Add > New Item > Code > Class > Name "SalesConfirmHeaderMy_Extension" > AddThis class is called "augmentation class" of table "SalesConfirmHeader"



  2. There are a few rules for augmentation classes outlined by Microsoft
      1. They must be final.
      2. They must be suffixed by _Extension
      3. They must be decorated with the [ExtensionOf()] attribute.
  3. So first we need to fulfil these rules. Our augmented class will look like below (screenshot)




  4. Now you can add new methods to the augmentation class.These methods will then appear in intelliSense for variable of the "SalesConfirmHeadrTmp" table.
    In my case i added a "myTestMethod()" which sets the value in my custom field
    "MyStrField"of that table.



     Note : please visit this link to add a new field in standard table using extension approach
  5. Now create a run-able job just to verify that custom added method is displaying in the intellisense or not.
    Right click on your project then Add > New Item > Code > Runnable Class (Job) > Name "VerifyMethodJob" > Add

  6. Now create a variable "salesConfirmTable" for table "SalesConfirmHeaderTmp"
    and as you can see in the screenshot below that custom added method is displaying in the intellisense which was defined in the augmentation class



Monday, June 24, 2019

Table extension to add a field

Table extensions provide a way to add fields to a table without over-layering.
This means that we don't need to perform a code merge when the base package is changed.

We will add a field to the " SalesConfirmHeaderTmp " table, which we will use in the How to customize a document layout without an over-layer recipe.

To add a field to a table as an extension, follow these steps:
  1. Run Visual Studio and create your project.
  2. Locate the " SalesConfirmHeaderTmp " table in the Application Explorer as shown in the screen shot below.

  3. Right-click on it and choose Create extension.
    Note: Please make sure that your project model should be correct.
    In the screenshot below my project model is " Fleet Management " which is incorrect.
    " Fleet Management " is not a extension model of " Application Suite " model that is why the " Create extension " is non clickable.



  4. Right-click on your project and go to " Properties "

  5. Property window will appear then select your appropriate model as shown in the below screen shot
    Note: " AXGuru_Customization " is my custom model which i created as an extension of " Application-Suite " Model
    For create a custom model visit this link click here


  6. Follow the step 3 again and you will see that " Create Extension " option is clickable



  7. Click on " Create Extension ".
  8. " SalesConfirmHeaderTmp.Extension " Table is added in your project,
    now right click on it and click " Open "

  9. Right click on the " Fields " note,
    Click " New " then select the type ( example : String, Integer,Real etc )

  10. In my case i am adding the " String " type field.
    and set it's properties.
    Name : Axg_Description
    EDT : Description

Tuesday, June 11, 2019

Create a new Extension Model

To create a new model, follow these steps:
  1. Open Visual Studio as admin.
  2. on the Dynamics 365 menu, point to Model Management and select Create model.

  3. Give a model name, publisher name , select layer and other values and press " Next "

  4. Now here we can create a new package or select any existing package.
    We could create a new package and select the required package as referenced packages

  5. As shown in the above screenshot i select the " Create new package " because i am creating a " Extension Model ".
  6. Now " Select referenced packages " window appears.
    When you create your own package you can select from an existing package to add them as references in your new package. You may need to add some standard package reference if you want to add them into your customization.
    As shown in the below screen shot i select the " ApplicationSuite " and some other packages as a referenced package of my custom model.

  7. Verify the summary with details.

  8. Click finish.

Post Event Handler

In Dynamics 365 F&O we are not allowed to add our custom logic in between the  core logic  but we can execute our custom logic before ...