Skip to main content

MSDYN365BC - AL Development 03 - How to Customize Base tables?

Hi Readers,

I am sure everyone was able to develop a table and page in AL based on Last articles in this series. If you haven't read the earlier article, then refer to the table of content.

As promised in this article we will customize base tables as per customer requirements.

The Customer requires new field added in below-listed base tables and set table relation to the new table created earlier.


Let's try to introduce new Object Type in Business Central i.e. Table Extension.

Table Extension is a new object using which we can add fields and functions in the base table without modifying Microsoft base objects.

Currently, let's add a new field in tables -
 - Sales Header.
 - Sales Invoice Header.
 - Sales Shipment Header.

Add a new file on the Left-hand Panel - right click and select New File as shown below.
As per our standard Table Extension file name is - SDH_TableExt_50000_SalesHeaderExt.al



Snippet for adding a new table extension, use snippet ttableext as shown below.



Next step to set (as shown below) - 

  • ID - Object ID.
  • MyExtension - Extended Object Name.
  • MyTargetTable - Extending Base Object Name.



Let's understand why and what we set.

ID - Object ID for the new object created.
Table Extension Object Name - Uniquely name of the new object created.
Base Object Name - Name of the Microsoft base object which we are extending or customizing.

By Default Table Extension snippet provides two sections which are -
 - Field Addition.
 - Global Variables.



But you can also add new sections (if required) like -
 - Keys.
 - Triggers.
 - Functions.


As you see above there are more trigger options in Table Extension than Table. Let's try to understand them.

Standard Triggers which everyone understands -
 - OnInsert.
 - OnModify.
 - OnDelete.
 - OnRename.

** All these triggers operates like normal table triggers but only for fields in the table extension.

Other 8 pairs (OnBefore & OnAfter) Executes on actual table i.e - 
  • OnBeforeInsert
  • OnAfterInsert
  • OnBeforeModify
  • OnAfterModify
  • OnBeforeDelete
  • OnAfterDelete
  • OnBeforeRename
  • OnAfterRename

We will discuss about these in future articles.

Now, let's add a new field that we want in sales header table using table extension using snippet tfield. As we need to set table relation to the new table created we will use to set the property for the field as shown below.



With table extension for sales header is ready. Follow the same steps for Sales Invoice Header and Sales Shipment Header Table Extensions.

As per our standard Table Extension file name are -

  • Sales Invoice Header Extension - SDH_TableExt_50001_SalesInvoiceHeaderExt.al
  • Sales Shipment Header Extension - SDH_TableExt_50002_SalesShipmentHeaderExt.al


Stay Tuned for more. I hope you learned something today.

We will discuss the page extension object in the next article. Please provide your feedback as comments to the article.

To share the knowledge share the article on social media.

Regards,
Saurav Dhyani

Comments

  1. More detailed explanation required for table relation. If possible add more about this here.
    Thanks.

    ReplyDelete
    Replies
    1. Its same as of C/Side. Do you want to know anything specific.

      Delete
  2. I would appreciate a more explanation of the table relation.

    ReplyDelete
    Replies
    1. Its same as of C/Side. Do you want to know anything specific.

      Delete

Post a Comment

Popular posts from this blog

Welcome - Microsoft Dynamics 365!

Hi All, In this article we will discuss the new introduced member of Dynamics Family. Yes you heard it correctly, one more new member with Name "Microsoft Dynamics 365" . #ProjectMadeira   #Dynamics365

Send Mail with Attachment From Navision.

Hi all, We have seen how to save a report into PDF and how to send mail to a customer. Let's link these two post in one i.e. Mailing statement to a customer into PDF Format. This article is part of the Series. Please Refer  Table of Content here . If you have the old objects set let me brief you what I will be changing - 

MSDYN365BC - Data Upgrade To Microsoft Dynamics 365 Business Central on premises.

Hi Readers, We have already talked about the number of steps for upgrading to Business Central on Premises from different NAV versions. After that article, I received multiple requests for an article which list down steps for Data Migration. In this article, we will discuss steps of data migration to MSDYN365BC (on-Prem) from NAV 2017. For this article, I am considering a Cronus Demo Database without any customization. For an actual upgrade project, we will have to complete object merge using compare and Merge process. After the Merge Process, the next step is data migration. Let's discuss those steps. Direct Upgrade to Microsoft Dynamics 365 Business Central (on-Prem) is from following versions - 1. NAV 2015. 2. NAV 2016. 3. NAV 2017. 4. NAV 2018.