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 - SDH_Table_50000_Sourceofsales.al


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.

Regards,
Saurav Dhyani
www.sauravdhyani.com

Comments

  1. Usefull Saurav. Keep up the Good Job!

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

      Delete
  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'.

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

      Delete
  3. Hi Saurav -

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

    ReplyDelete
  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?

    ReplyDelete
    Replies
    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 -
      https://saurav-nav.blogspot.com/2019/10/msdyn35bc-2019-wave-2-how-do-i-check.html

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

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

      Delete

Post a Comment

Popular posts from this blog

BC 21 and Higher - PowerShell Cmdlet (Replacement of Business Central Administration).

Hi Readers, As discussed in last article about deprecating of Business Central Administration, there are few common actions that we use in administration till Business Central 20. For our on-prem customers, we will still require doing activities. As Microsoft suggest we need to start using PowerShell cmdlet.    Let's see how to do those via PowerShell, or Administration Shell. I will be keep adding commands as you comment to this article.

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.