Skip to main content

MSDYN365BC - AL Development 04 - How to Customize Base Pages?

Hi Readers,

I am optimistic that everyone was able to follow what we discussed till now. If you haven't read the earlier article, then
Refer to the Table of Content.

So in this article, we will add fields added in tables in the pages so that user can access those fields.

The customer Requires new fields added in few standard pages.
In this article, we will learn a new object type in Business Central i.e Page Extension.

Page Extension is a new object type using which we can add fields, actions, and functions in the base pages without modifying Microsoft Base Objects.

Currently, let's add a new field in pages -

  • Sales Order.
  • Posted Sales Shipment.
  • Posted Sales Invoice.

Add a New file on the Left-hand Panel - Right click and select New File as shown below.
As per our standard Page Extension file Name is - SDH_PageExt_50000_SalesOrderExt.al



Snippet for adding a new page extension, use snippet tpageext as shown below.


Next step is to set the following properties (as shown below) - 

ID - Object ID.
MyExtension - Extended Page Name.
MyTargetPage - Extending Base Page Name.


Let's understand why and what we set.

ID - Object ID for the new object created.
MyExtension - Unique Page Extension Object Name.
MyTargetPage - Name of the Microsoft base page name which we are extending or customizing.

By Default Page Extension Provide three sections -

  1. Layout - To Add New Fields in the page.
  2. Action - To Add New actions on the page.
  3. Global Variables.



But You can also add additional sections (if required) like -
- Triggers.
- Function.


Triggers for are the page is below -

  • OnAfterGetCurrRecord.
  • OnAfterGetRecord.
  • OnClosePage.
  • OnDeleteRecord.
  • OnInsertRecord.
  • OnModifyRecord.
  • OnNewRecord.
  • OnOpenPage.
  • OnQueryClosePage.

So after all these let's add the field that we want to add in this Sales Order Page using Page Extension.

Remember - 
1. All Fields in the page are added in Layout Area.
2. Adding a field in Page using Page Extension will be a bit different than adding a field in a table using table Extension.

As we want to add a field in Page (Sales order page), we need to tell the system where we want to add the field. There are 04 options that we can choose from while adding a field in the page. Let's understand why and what are those options.


Above is a screenshot of the Sales order Page. Now while adding a field in this page, we need to specify under which section and at what position we want to add the field.

AL Provide us 04 options to specify the position of a new field that we are adding and those options are -

  • AddFirst    - Add as first control in a tab.
  • AddLast     - Add as last control in a tab.
  • AddBefore - Add field before a standard field in the page.
  • AddAfter   - Add field after a standard field in the page.
For AddFirst & AddLast, we need to specify the anchor Group Name and for AddBefore & AddAfter, we need to specify anchor field Name.


What is Anchor? - The name of the control serving as an anchor for placing the new control.

Let's assume I want to add my field after External Document No. then -

  • We can use Addafter with an anchor External Document No.
  • For adding a field in the page you can use tpagefield snippet.
  • Specify the Field Name and Source Expression in the field.
  • For the Field, we can also add properties. As we discussed earlier there is a mandatory property for user-visible items like fields i.e ApplicationArea. 
  • If you want to have to see the field in every case then you remember NAV Page Field Property Importance. 


With this, the Page Extension is ready for Sales Order. In the same way, you can complete all other page extensions as shown below.

Sales Order Extension  - SDH_PageExt_50000_SalesOrderExt.al



Posted Sales Invoice Extension - SDH_PageExt_50001_PostedSalesInvoiceExt.al



Posted Sales Shipment Extension - SDH_PageExt_50002_PostedSalesShipmentExt.al



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

We will discuss more in the next article. Please provide feedback as comments to the article.

To share the knowledge share the article on social media.

Regards,
Saurav Dhyani

Comments

  1. Detailed explanation is required for Importance property, then it is more understandable.

    ReplyDelete
    Replies
    1. Hope this helps.
      https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/properties/devenv-importance-property

      Delete
  2. Excellent article. Very useful and very informative. Great Job Saurav. Thanks Spriya.

    ReplyDelete

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.