Creating a Wizard Page in AL for Business Central

In today’s post we will learn to create Wizards.

First Let us understand why we use wizards.

  • We can define wizard as series of user input screens or steps.
  • You can show/hide options for each step based on previous step selection that is relevant to complete any setup process.
  • User can navigate between steps with Next and Previous buttons.
  • In Web Client it shows buttons with specific styling.
  • We define Page with type NavigatePage.
  • Plays crucial part in Assisted Setup.

Without going into much theory let’s start creating a Wizard Page.

Step: 1 –

Create a New Page of type NavigatePage.

CI-1

Create *.al file in your VSCode Project, you can use tpage snippet.

Set the Unique available ID in your database and Extension.

Give meaningful name to your file.

Set the PageType property to NavigatePage.

Set SourceTable property to the base table in my case “Company Information”

Step: 2 –

Add a Group for each Step you wish for your Setup, in my case I am using 3 Step.

Create Global variable CurrentStep of type Integer, this will help making decision on which step you are currently and act accordingly.

CI-2

On each Group, Set the Visible property with an expression:

Visible – CurrentStep = 1;

And so on.

Step: 3 –

Create a sub-group inside the steps and set the suitable Caption.

Set InstructionalText to provide guidance

Add fields to the sub-group

CI-3

And similarly to other groups.

Step: 4 –

Add three actions to facilitate navigation.

For each action, set the InFooterBar property to true.

When this is used in combination of PageType NavigatePage, it will show action as navigation buttons.

CI-4

Step: 5 –

Create 3 global variables as Boolean, say ActionBackAllowed, ActionNextAllowed, ActionFinishAllowed

On each action, set the Enabled property to the appropriate global variable.

Set the Image property of your actions:

Back : PreviousRecord

Next : NextRecord

Finish : Approve

CI-5

Step: 6 –

Create function/procedure to SetControls, TakeStep and Set starting values in the OnOpenPage trigger.

CI-6

Step: 7 –

Now we will add OnAction trigger to the navigation actions.

CI-7

Step: 8 –

Now we will create 2 global record variables for Media Repository table and for the Media Resources table.

CI-8

Step: 9 –

Now add 2 new groups above Step 1 Group.

Add field to each group.

Set source expression to the Image field of the Media Resources variables.

Set ShowCaption property to false.

CI-9

You see error for TopBannerVisible let’s define a global variable of type Boolean.

Step: 10 –

Now we will Add a function to Load the top banner images.

Call this function from OnInit trigger.

CI-10

We are done with our base design of Wizard.

Now time to deploy and Test.

For testing purpose let’s hook it to some page and see the result.

Although it is not correct place but for testing purpose let’s add to our existing page created in earlier post “Loadout List” page and test the output.

CI-11

Added new action on “Loadout List” Page, just to check the output. I will come up with Assisted Setup in our next post and hook it there.

Now we will Build and Deploy the Extension and review what we created.

CI-12

Access your Loadout Point List Page from Sales Order Line and Run the Wizard.

Let’s run the same from the Web Client.

ci-13

ci-14

I will come up with linking this Wizard Page to Assisted Setup in our next post.

AL Basics – Part 4 [Page]

Today we will see how to create pages in AL.

Before we dive into it lets have some basic concept for Pages.

If you navigate in Navision you may be familiar with page types we have in Navision.

Types of Page

  • Card Page
  • List Page
  • CardPart Page
  • ListPart Page
  • Worksheet Page
  • Document Page
  • RoleCenter Page
  • Confirmation Dialog Page
  • ListPlus Page
  • StandardDialog Page
  • Navigate Page

All above pages are just how we design and use them for specific purpose, I will not go in details what type of page is used for what purpose you can find them in any document or already familiar with.

When we design pages we should have idea of Page Controls

Different Page Controls you have on pages are:

  • Actions
  • Content Area
  • Factbox Area
  • RoleCenter Area

All controls are placed in pages using below arrangement

Type SubType
   
Container Content Area
  FactBox Area
  RoleCenter Area
   
Group Group (Fast Tabs – on Card Pages)
  Repeater (List Pages)
  CueGroup (Rolecenter Pages)
  FixedLayout
  Grid layout
   
Field Data from Table
   
Part Display another Page, Chart, System defined features

Lets understand from below Customer List Page

Pag-1

Let’s create our First Page.

To Create a Page First we will create a File .al.

In Editor we fill type snippet tpage

You will get the options available, select Page of type list, we are going to create List Page.

Pag-2

Basic structure of the Page is given to you as below

Pag-3

Lets create our LoadoutPointList Page on Table Loadout Point table created in previous post.

Pag-4

Similarly we will create a Appointment Calendar Setup List Page, final code as below:

Pag-5

Similarly you can design Card Page Also:

I am not creating Page from scratch but will show you few properties, triggers from standard Page e.g.:- Cost Type Card

Pag-6

PageType you need to define as Card.

For FastTab you need to define group.

Pag-7

Above is the example of few properties for field control on Page.

Pag-8

To add factboxes to the page you define area(factboxes).

Here systempart for Links & Notes is added.

Pag-9

Above is actions to the page. Few properties how to define.

Pag-10

Above is the Page triggers.

Complete code for each objects is not possible to include in post.

But I will give to some tips using which you can explore equivalent AL Code and tryout them.

Suppose you want to see any feature how implemented in Customer Card.

Export that object as text, and convert using txt2al for equivalent al code.

You can refer back to my previous post Quick Start with Extensions for Business Central

Similar method I have explained in this post.

Pag-11

We will explore few more possibilities and Extending to existing Table & Pages in our upcoming post.

 

How can I Drill Down to any Page dynamically using Table ID

There is a requirement from my one of my reader.

Today I will discuss on how we can dynamically open page by using table ID only.

As you are aware to open Page we require PageID and Table record.

PAGE.RUN(Number [, Record] [, Field])

For this we will use RecordRef and minimum requirement is table have Page ID for Lookup and Drilldown defined else we will get error when try to open the page.

 

Create a Function name it say ShowRecords.

Define 2 Variables as:

Name rRef

DataType RecordRef

Name varRecRef

DataType Variant

 

We require VARIANT because PAGE don’t accept RecordRef datatype.

PAGE.RUN(Number [, Record] [, Field])

Also define Parameter to the function to receive Table ID.

 

In function you write below code:

 

rRef.CLOSE;

CLEAR(rRef);

//rRef.OPEN(No [, Temp] [, CompanyName])

rRef.OPEN(TableID,FALSE,COMPANYNAME);

//You can apply filters also if required before accessing the Page

varRecRef := rRef;

//PAGE.RUN(Number [, Record] [, Field])

PAGE.RUN(0,varRecRef);

 

Now where you require you can call your function as ShowRecords(18)

This will Open Customer List Page to show the records from table.

I will show good use of same in my upcoming post. One use can be to design Navigate Page but few limitations will apply, wait for my next post.

 

That’s all for this post, I will come up with more details in my upcoming posts, till then keep exploring and learning.

 

 

Creating Views – to Save Filtered Lists in NAV

Do you Know you can save the Page as View with filters.

Many of time we access to Page and apply same set of Filters to fetch our data. You can save the same for quick retrival of data applying the filters automatically in future access.

You save the Page with Filters as View.

Let us see small example how to achieve it.

First we will open the List Page in my case i am having one customized Customer List.

FilteredView-1

Suppose this is the Page which i use for Balances Retrival each month and on daily basis.

I Enter Filter as Balance > 5000 & Current Month Filter whenever i wish to check balances for my reporting or followup purpose.

For Date Filter i use (-CM..CM) sothat when i open this view next month it takes the appropriate Filter for that month.

FilteredView-2

Click on the Page Name post applying all the required Filters.

Select Save View as.

Give the Name for the View.

Select the Location to save the View.

On Confirmation respond as Yes.

FilteredView-3

Your View will be Saved, You can create as much Views as desired using different Filters.

FilteredView-4

Small and good Feature.

What you are waiting for give it a try.

I will comeup with more information in my upcoming posts, till then keep exploring and learning.

 

 

Setting different Column Layout for different users

On Community Forum i came across one requirement for opening Page with different column on Page for different users.

Here i have given an demo how can be done, but will require some tweaking to achieve the actual result.

I have copied the Customer List Page and removed extra fields.

Playing with columns1

I have added one Field above Repeater so that we can decide which format we want to see on screen. User can enter 1/2/or any other value.

I have created two more variables Set1 and Set2 to show/hide fields as per the value entered in SetSelect.

Assigned the Set1 & Set2 to few columns on the Page Fields to Property Visible.

Set1 to Responsibility Center, Location Code & Currency Code.

Set2 to Post Code, Country/Region Code, Phone No. & Fax No.

Added code on OnOpenPage Trigger to select Default page Format when Page is Opened. This code you will modify as per your requirement like check the User and assign the default Value.

Added Code to SetSelect-OnValidate Trigger to select the required format of Page. You need to modify the code as per your requirement.

Playing with columns2

In this demo if user enter value for SetSelect and you will get different view of same page.

Do some research and design one as per your requirement, this way we need not to create different Pages for different Users. Same Page can serve you different purpose if limited to only different views.

I will come with more information in my upcomming posts.

Till then keep browsing and learning.

 

Which Properties are Restricted in Extension Packages

For Overview, please see my earlier posts

Introducing Extensions in Microsoft Dynamics NAV 2016

Which Object types you can Include & Restrictions applicable to C/AL code in Extension Packages

Restricted Properties on Existing Page Modifications

You cannot change the values for the following properties for existing Microsoft Dynamics NAV pages in an extension.

  • AccessByPermission
  • AssistEdit
  • AutoSplitKey
  • CardPageID
  • CharAllowed
  • ContainerType
  • ControlAddIn
  • Data Type
  • DataLength
  • DateFormula
  • DelayedInsert
  • DeleteAllowed
  • DrillDown
  • DrillDownPageID
  • Editable
  • ExtendedDatatype
  • FieldClass
  • GroupType
  • ID
  • InsertAllowed
  • LinkedObject
  • Lookup
  • LookupPageID
  • MaxValue
  • MinValue
  • ModifyAllowed
  • MultipleNewLines
  • Name
  • NotBlank
  • Numeric
  • PageType
  • PartType
  • PasteIsValid
  • Permissions
  • PopulateAllFields
  • RefreshOnActivate
  • SourceExpr
  • SourceTable
  • SourceTableTemporary
  • SourceTableView
  • SubType
  • SystemPartID
  • TableRelation
  • TableType
  • TestTableRelation
  • ValidateTableRelation
  • ValuesAllowed

Most of these are typically not properties changed through customization as they can have a negative effect on the Microsoft Dynamics NAV deployment.

 

 

Restricted Properties on Existing Table Modifications

You cannot change the values for the following properties for existing tables and fields in an extension.

Table Properties Field Properties
  • Name
  • DataPerCompany
  • Permissions
  • LookupPageID
  • DrillDownPageID
  • PasteIsValid
  • LinkedObject
  • TableType
  • Name
  • AccessByPermission
  • Compressed
  • Data Type
  • DataLength
  • DateFormula
  • ExtendedDataType
  • FieldClass
  • MaxValue
  • MinValue
  • NotBlank
  • Numeric
  • Owner
  • SQL Data Type
  • SubType (BLOB)
  • TableIDExpr
  • TableRelation
  • TestTableRelation
  • ValidateTableRelation
  • ValuesAllowed Width

You can add table keys, but you cannot delete or modify existing keys.

You can add fields to a table group, but you cannot remove fields or groups.

Page Properties Not Supported by Microsoft Dynamics NAV Web Client

Most page properties that are supported in the Microsoft Dynamics NAV Windows client are also supported in the Microsoft Dynamics NAV Web client.

There are some properties that are not supported by Microsoft Dynamics NAV Web client and other properties that are either partially supported or behave differently in the Microsoft Dynamics NAV Windows client.

Unsupported Properties

The properties that are not supported by the Microsoft Dynamics NAV Web client. When a page that contains an unsupported property is displayed in a browser, the property is ignored. You do not receive an error but the property does not affect the page.

  • ChartPartID Property
  • ColumnSpan Property
  • ControlAddin Property
  • FreezeColumnID Property
  • RowSpan Property
  • RefreshOnActivate Property
  • ShowAsTree Property
  • Style Property
  • StyleExpr Property
  • SystemPartID Property

Partially Supported Properties

The properties that either do not have all the capabilities in the Microsoft Dynamics NAV Web client as they do in Microsoft Dynamics NAV Windows client or they behave differently than in the Microsoft Dynamics NAV Windows client.

  • AssistEdit Property
  • DrillDown Property
  • DrillDownPageID Property
  • GroupType Property
  • Importance Property
  • IndentationControls Property
  • PageType Property
  • PartType Property

New Properties and Controls for Pages – in Navision 2015

ShowMandatory Property

With Microsoft Dynamics NAV a new property called ShowMandatory has been introduced on page fields. The ShowMandatory property is set on page fields and marks the field with a red asterisk on the UI.

You can refer this in my earlier post Show Mandatory Property

UpdatePropagation Property

In Microsoft Dynamics NAV a new property called UpdatePropagation is added to page fields. The introduction of this property makes it possible to update a parent page from a subpage automatically without using the page Refresh button.

You can refer this in my earlier post UpdatePropagation Property

Scope Property

In Microsoft Dynamics NAV a new property called Scope is added to page actions. The introduction of this property specifies the scope of an action to be either page-specific, or specific to a repeater control.

You can refer this in my earlier post Defining Action Scope for Microsoft Dynamics NAV Pages in Navision 2015

FixedLayout Control

Microsoft Dynamics NAV now supports using the FixedLayout control on the Microsoft Dynamics NAV Web client.

You can refer this in my earlier post Using a FixedLayout Control

Viewing Page Data in Excel Using PowerPivot (OData)

Here I will discuss how you can use OData to expose a Microsoft Dynamics NAV 2015 page as a web service and then analyse the page data using Microsoft PowerPivot for Excel 2013.

With OData and PowerPivot, you gain access to a powerful set of tools and technologies for data exchange and analysis.

This walkthrough illustrates the following tasks:

  • Publishing a Microsoft Dynamics NAV page as a web service.
  • Verifying web service availability from a browser.
  • Using the PowerPivot add-in for Excel to import the table data as a new worksheet.
  • This procedure also includes optional instructions about how to use a web service access key.
  • Creating a PivotTable from the worksheet, selecting relevant fields, and then organizing and formatting the data to highlight strategic data.

Optional:

If you want to use a web service access key to authenticate access to the web service, Microsoft Dynamics NAV must meet the following requirements:

The Microsoft Dynamics NAV Server is configured to authenticate users by using the NavUserPassword credential type.

There is a Microsoft Dynamics NAV user account that has a web service access key.

You can find more details in my earlier post here

Publishing a Page as a Web Service

You can publish a web service by using the Microsoft Dynamics NAV Web client or the Microsoft Dynamics NAV Windows client.

To register and publish a page as a web service

  • Open the RoleTailored client and connect to the CRONUS International Ltd. company.
  • In the Search box, enter Web Services, and then choose the related link.
  • In the Web Services page, choose New.
  • In the Object Type column, select Page. In the Object ID column, enter 21, and in the Service Name column, enter Customer.

This exposes the Customer Card page as an OData web service.

  • Select the check box in the Published column.

Choose the OK button to close the New – Web Services page.

PowerPivot-1
Verifying the Web Service’s Availability

Security Note

After publishing a web service, verify that the port that web service applications will use to connect to your web service is open. The default port for OData web services is 7048. You can configure this value by using the Microsoft Dynamics NAV Server Administration Tool.

To verify availability of a Microsoft Dynamics NAV web service

Start Windows Internet Explorer.

In the Address field, enter a URI using the following format: http://Server : WebServicePort/ServerInstance/OData/

Server is the name of the computer that is running Microsoft Dynamics NAV Server.

WebServicePort is the port that OData is running on. The default port is 7048.

ServiceInstance is the name of the Microsoft Dynamics NAV Server instance for your solution. The default name is DynamicsNAV80.

For example, if the Microsoft Dynamics NAV Server is running on the computer that you are working on, you can use: http://localhost:7048/DynamicsNAV80/OData/

In my case: – http://indel-axt5283n1.tecturacorp.net:8048/DynamicsNAV80/OData/

The browser should now show the web service that you have published, as shown in the following illustration.

PowerPivot-2
Note

If the browser cannot find the web service, it may indicate that the specified Microsoft Dynamics NAV Server instance is not running.

Make Sure Enable OData Services is checked.
PowerPivot-3
Importing Microsoft Dynamics NAV Data into Excel

In the following procedures, you use PowerPivot to import Microsoft Dynamics NAV data into Excel. If you will be using a web service access key for authentication, only perform the second procedure; otherwise, only perform the first procedure.

To import Microsoft Dynamics NAV data into Excel

Start Microsoft Excel.

In Excel, on the PowerPivot tab, choose Manage.

PowerPivot-4
This opens the PowerPivot for Excel window.
PowerPivot-5
In PowerPivot, on the Home tab, choose Get External Data, choose From Data Service, and then choose From OData Data Feed.

The Table Import Wizard opens.

PowerPivot-6
If your Microsoft Dynamics NAV implementation requires that you use a web service access key, you must specify the NavUserPassword credentials as described in the following steps:

In the Advanced dialog box, in the Security section, set the Integrated Security field to Basic. If your OData is configured to use SSL, then set the field to SSPL.

In the Password field, type the web service access key.

In the UserID field, type the user name for the Microsoft Dynamics NAV user account. For this walkthrough, use NavTest.

In the Source section, in the Service Document URL field, type the URL for the OData web service that you verified in the previous procedure, for example, http://localhost:7048/DynamicsNAV80/OData/.

In my case: – http://indel-axt5283n1.tecturacorp.net:8048/DynamicsNAV80/OData/

Choose the OK button to return to the Table Import Wizard.

In the Connect to a Data Feed page, in the Data Feed Url field, enter the OData URI that you verified in the previous procedure.
PowerPivot-7

Choose the Next button.

Important: The URI must end with a slash (/) as shown in the example.

Verify that Customer appears in the Source Table column.

Select the check box next to the Customer web service, and then choose Finish.
PowerPivot-8
After you see the Success message, choose the Close button.
PowerPivot-9

The data from the Customer OData web service displays, and you can use the data to build pivot-based views in the Excel workbook.

Creating a PivotTable Containing Key Microsoft Dynamics NAV Data

In this procedure, you use the Excel workbook with data from the Customer web service to create a PivotTable from the worksheet. You select relevant fields and then organize and format the data to highlight strategic data. Building a pivot table is a way to select and arrange data so as to highlight and focus on key elements.

To create a PivotTable

In Excel, select the cell where you want the PivotTable located.

In the ribbon, choose the Insert tab, and then in the Tables group, choose PivotTable.

In the Create PivotTable dialog box, select Use an external data source, and then choose the Choose Connection button.

In the Existing Connections dialog box, on the Connections tab, under Connections in this Workbook, choose the data feed for your OData web service, and then choose the Open button.
PowerPivot-10

Choose the OK button to add the PivotTable to the Excel worksheet.

The PowerPivot Field pane on the right side includes a list of fields from the Customer web service that where imported from PowerPivot.

In the PowerPivot Field List pane, choose Location_Code.

Tip

To quickly find a field in the field list, type part or all of the field name in the Search text box that is above the list of fields, and then press Enter to highlight the first field that contains the text. You can then choose the right arrow to proceed to the next field, and so on.

Select the Balance_LCY field.

Select the Name field.

You can now see the data in the body of the worksheet, as shown in the following illustration.

The PivotTable shows customers by location and individual customer balances, and also adds the balances by location. To make the information more readable, you can update the headings on the PivotTable.
PowerPivot-11

Select the cell that has the heading Sum of Balance_LCY, and then, in the formula field, type Balance.

Select the cell that has the heading Row Labels, and then in the formula field, type Customers by location.

Select the empty cell that is below the Customers by location cell, and then, in the formula field, type Location not specified.

The above illustration shows how the worksheet looks after you make these changes.

Next Steps

Now that you have created your PivotTable, you can continue to enhance the data to make it more useful and readable. You can:

Add a column to the data that shows average balance by region.

Enhance data presentation with a graph.

Post the data in a Microsoft SharePoint environment with live data from Microsoft Dynamics NAV 2015.

Previous Older Entries

Important

Most of the contents you find in this blog will be either inherited from MSDN or Navision Developer IT Pro Help. Some places images are also directly taken from these sites. Purpose is simple to try those stuffs and re-produce adding few things as per my understanding to make easy understanding for others and quick reference.

Here nothing under my own brand or authorship of the content. At any point of time we are just promoting Microsoft stuffs nothing personnel with same.

Hope stuffs used here will not violate any copyright agreement with them. In case by mistake or in-intestinally it happens and the Microsoft feels these should not be used Microsoft have full right to inform me about same and will be glad to take down any such content which may be violating the norms.

Purpose is to promote Navision and share with community.

FB Profile

Like FB Page

%d bloggers like this: