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

Dynamics NAV - All that you need to know about MenuSuites.

Hi Readers, This article is based on a request from a blog reader who wanted to understand about MenuSuite in Dynamics NAV. If you have started working with Business central with AL Code then it does not apply to those releases but if you are interested go ahead. Let's start with Future - In Latest and greatest version of product MenuSuite are obsolete and no longer used. So this article applies if you want to learn about C/AL MenuSuite.

How to Set Up NavUserPassword Authentication in Business Central.

Hi Readers, In this article we will discuss steps to Setup NAVUserPassword in Business Central on-prem. NavUserPassword is an authentication method that's handled by Business Central Server, but isn't based on Windows users or Active Directory. Each user is set up with a username and password that's configured inside Business Central only. The user is prompted for username/password credentials when they start the client. #msdyn365bc, #credentialtype

Microsoft Dynamics NAV 2016 - How to Configure Phone Client.

Hi All, In this article we will discuss how we can connect Microsoft Dynamics NAV 2016 with New Client Launched i.e. Phone Client. This Article Contain Steps for a Android Phone as I have Only Android Phone. I am doing it having all tiers on my windows 8 machine, steps remain same for multiple servers but issues might be different. What we Need (Other what we discuss in this article) -  The Service Tier should be on Public IP . Some of the Data-card does not Provide you Public IP. check it for sure.