Skip to main content

MSDYN365BC - AL Development 01 - How to Develop New Table in Database?

Hi Readers,

I am sure you have completed all Prerequisites, as listed in Customer Requirements article (first article in this series).

Please Refer Table of Index for AL Dev.

As promised in this article we will build the new table as per customer required.

The customer requires a new table to set up master for Source of Sales. Below is the field list that we plan to have it on the table.

Let's try to add this table to our extension.
Add a New file on Left-hand Panel - right click & select New File as shown below.

** Plan a file naming standard for your company or you as an individual developer. I am using a combination of -

  • Developer Initials / Company Initials
  • ObjectType
  • ObjectID
  • ObjectName
So my table file name is -

AL provides a list of the snippets to make it easy for developers to add objects in extension. Snippet for getting a table layout use snippet ttable as shown below.

Assign ID and provide a name to the table that you are adding, as shown below.

Click tab after ttable and it will generate a basic table design layout as shown below.

You can segregate the whole table into 4 Sections -
  • Field Section - This section contains all the fields that you want to add to the table.
  • Key Section - All Primary and Secondary key can be added to the following areas.
  • Global Variable Section - All global variables are added in this section.
  • Table Trigger Section - All base table triggers are available in the areas. If required you can add code in this section.
Plus, If you don't need any of these sections you can delete that section (which you cannot do in NAV / CAL).

Let's add fields in the table as discussed above and see how easy it. For adding a new field you can also use snipped tfield as shown below.

The area between {} inside a field, where you can add field properties. But in NAV you can see using Shift+F4, but in AL you can use Ctrl + Spacebar, to see all field list, as shown below.

To Showcase functions usages, we will add an additional field - "Last Modified Date Time", which get set whenever the record is added or modified. Below are the fields and code added in the table.

We will require to have a local function (procedure), to update "Last Modified Date Time" and then calling that function from OnInsert, OnModify, and OnRename as shown below.

As our table design is completed, you will see an error message about the object number in the Problem area below. There is an object range for each extension that you can define. Update your number series in the app.json as shown below.

This will end all issues/problems that you will have.

Stay tuned, we will discuss about pages in this series next article. Let me know your views on how easy/difficult it is.

Saurav Dhyani


  1. Usefull Saurav. Keep up the Good Job!

    1. Great to hear that you find the information useful.

  2. hi saurav

    i am doing the same thing but getting below error while publishing.

    The request for path /BC130/dev/apps?SchemaUpdateMode=synchronize failed with code 422. Reason: Your program license does not allow you to publish 'Source of sales'.

    1. @Sanjeet,
      You need to have partner licensce saved in database or uploaded on server.
      After uploading licensce please restart service tier.

  3. Hi Saurav -

    Thank you for such a wonderful article. Thanks for sharing your wealth of knowledge about Wave 2.

  4. Hi Saurav,
    If I use Object Series from 50100 to .. then it is fine.
    If i want to use series from 50000, how to upload license?

    1. Hi Nitin,
      If you are using BC 13/14 then you can use development environment.
      For Business Central 15 or higher you can do that as discussed in article -

  5. Its really useful for beginners like me. A big thanks for such series. Pl. publish more series like this.

    1. Great to hear that you find the information useful.


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.