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

VIEW SERVER STATE permission on SQL Server?

Hi all, Sometime While trying to Login into a database we face an error message as shown below. --------------------------- Microsoft Dynamics NAV Classic --------------------------- You cannot start Microsoft Dynamics NAV Classic because you do not have the VIEW SERVER STATE permission on SQL Server. Contact your system administrator. --------------------------- OK    ---------------------------

NAV 2013 R2 - Cumulative update 12 Released.

Hi all, Please find below the details of  Cumulative Update 12 released for Microsoft Dynamics NAV 2013 R2. Title - Cumulative Update 12 for Microsoft Dynamics NAV 2013 R2 Build No. - 38053 Release Date - October, 2014 Local Version Included - AU, AT, BE, CH, DE, DK, ES, FI, FR, IS, IT, NA, NL, NO, NZ, SE, UK, RU Download Link Note: Implementing this cumulative update will require a database conversion unless you have already implemented update rollup 5.

NAV 2013 Upgrade Part III - Data Upgrading.

Hi all, As per agenda we need to discuss the data upgrade in NAV 2013. The process is similar to what used to be till NAV 2009 R2 but with some changes. Let's start the process. Remember -  1) You can only upgrade a database to NAV 2013 from NAV 2009 SP1 / R2 SQL Only. 2) The Synchronization of users with SQL Server is no more required.