25 December 2016

Developing Extensions in Visual Studio Code with New Development environment NAV

Hi All,

Visual Studio Code and the AL Extension lets you do the following tasks
  • Create new files for your solution
  • Get assistance with creating the appropriate configuration and setting files
  • Use code snippets that provide templates for coding application objects
  • Get compiler validation while coding
  • Press F5 to publish your changes and see your code running
Visual Studio Code manages projects by including all files from a directory. Whatever files exist in that directory are then part of your project.

In addition there are two other configuration files; app.json and launch.json. You can define these yourself, possibly by copying the files from sample code or you can have the system autogenerate them for you.

Building the solution (Ctrl+Shift+B) will create the app.json file and publishing (F5) will generate the launch.json file. Within these files, you’ll need to set up some parameters to connect to your server.

Ex: Here we will create an Extension to an Item table with a new field and add a validation to the new field created.

1) First Create a Project Folder and select that Folder from Visual Studio Code. Or you can start from Visual Studio Code and create folder and files from there itself.




2) You can Copy the launch.json and app.json file from other sample projects or else you can allow visual studio to create it automatically during building and publishing the project.

3) Add New file by clicking on New Icon and give it a Name and save it as .al extension. Saving it in .al extension will activate the AL Language Extension for Visual Studio Code. In the same file we will add our code.




4) Now in the Code Editor type in ttableext and the IntelliSense will bring in the code snippet for you.






5) Now change the code to add new field on Item table and similarly add the new field on item card page with validation on it by using page extension.

Below is for table extension



Below is for page extension



6) Now press Ctrl+Shift+B to build the solution and resolve if any errors. It will create .navx extension file.


And press F5 to publish the Package which is created on to NAV server.



7) Now let us verify whether the field has been added from NAV RTC and whether our validation is working. You can also see the published/installed extensions under Extensions Page in NAV RTC.





Note:

Below are the settings available in app.json and launch.json files.

Settings in the app.json file:
SettingMandatoryValue
idYesThe unique ID of the extension. When app.json file is automatically created, the ID is set to a new GUID value.
nameYesThe unique extension name.
publisherYesThe name of your publisher, for example: NAV PartnerLLC
applicationYes, if base application objects are extended or referencedThe minimal supported version and locale of the base application to extend, for example: { "version": "10.0.0.0", "locale": "W1" }
platformYes, if system tables are referenced in the extensionThe minimal supported version of the platform symbol package file, for example: "10.0.0.0". See the List of objects in the platform symbol file section below for the list of object symbols contained in the platform symbol package file.
packageCachePathYes, if base application is extended or system tables are referencedThe path to the folder where referenced symbol package files are located. The path could either be absolute or relative to the current extension working directory, for example: "../../resources"
Settings in the launch.json file:
SettingMandatoryValue
serverYes, if connecting to an on-premises serverThe HTTP URL of your server, for example: http://localhost
serverInstanceYes, if connecting to an on-premises serverThe instance name of your server, for example: NAV
portNoThe port on which the development endpoint is running on the server, default value: 7049
tenantNoThe tenant ID in case the server is configured for multitenancy.
windowsAuthenticationNoSpecifies whether Windows or Azure authentication should be used for publishing the extension. Currently only Windows authentication is supported.
startupObjectIdNoThe ID of the startup object to launch when you press F5. Currently only objects of type Page are supported.


Thanks & Regards,
Nandesh Gowda

24 December 2016

Understanding Objects and Sample Code Snippet Extensions for New Development Environment

Hi All,

In my last post I discussed on how to setup Azure 30 days free trial subscription and install a New VM for trying out New Development Environment. Below is the link for the same post.

https://nandeshgowda-navblog.blogspot.in/2016/12/developing-extensions-using-new.html


Understanding Objects in Dynamics NAV

All functionality in Dynamics NAV is coded in objects. Table objects define the table schema that holds data, page objects represent the pages seen in the user interface and codeunits contain code for logical calculations and for the application behavior. These objects are stored as code, known as AL code, and are saved in files with the .al file extension.

Note
A single .al file may contain multiple objects.

For Table Object please refer below MSDN Link
https://msdn.microsoft.com/en-us/dynamics-nav/newdev-table-object

For Page Object please refer below MSDN Link
https://msdn.microsoft.com/en-us/dynamics-nav/newdev-page-object

For Codeunit Object please refer below MSDN Link
https://msdn.microsoft.com/en-us/dynamics-nav/newdev-codeunit-object

There are two other special objects which are specifically used for building extensions. Table extension objects and page extension objects are used for defining additive or overriding changes to table or page objects.

For example, an extension for managing a business that sells organic food may define a table extension object for the Item table that contains an additional field Organic and Produced Locally. The Organic and Produced Locally fields aren't usually present in the Item table, but through the table extension these data fields will now be available to store data in and to access from code.

You can then use the page extension object to display the fields that you added to the table object.

Note :
Table and page extension objects can have a name with a maximum length of 30 characters.


1) Table Extension Object :

The table extension object allows you to add additional fields or to change some properties on a table provided by the Dynamics NAV service. In this way, you can add data to the same table and treat it as a single table.

For example, you may wish to create a table extension for a retail winter sports store. In your solution you want to have ShoeSize as an additional field on the customer table. Adding this as an extension allows you to write code for the customer record and also include values for the ShoeSize.

Along with defining other fields, the table extension is where you write trigger code for your additional fields.

Snippet support :
Typing the shortcut ttableext will create the basic layout for a table extension object when using the AL Extension in Visual Studio Code.

Properties:
Using a table extension allows you to overwrite some properties on fields in the base table. The following properties can be changed.

  • OptionCaptionML
  • ClosingDates
  • Description
  • Width

Table Extension example :
This table extension object extends the Customer table object by adding a field ShoeSize, with ID 70000900 and the data type Integer. It also contains a procedure to check if the ShoeSize field is filled in.
tableextension 70000020 RetailWinterSportsStore extends Customer
{
    fields
    {
        field(70000900;ShoeSize;Integer) 
        {
            trigger OnValidate();
            begin
                if (rec.ShoeSize < 0) then
                begin
                   message('Shoe size not valid: %1', rec.ShoeSize);
                end;                    
            end;
        }
    }

    procedure HasShoeSize() : Boolean;
    begin
        exit(ShoeSize <> 0);
    end;

    trigger OnBeforeInsert();
    begin
        if not HasShoeSize then
            ShoeSize := Random(42);
    end;
}

2) Page Extension Object

The page extension object extends a Dynamics NAV page object and adds or overrides the functionality.

The structure of a page is hierarchical and breaks down into three sections. The first block contains metadata for the overall page; the type of the page and the source table it is showing data from. The next section; the layout, describes the visual parts on the page. The final section details the actions that are published on the page.

In the layout section, you can use the following functions to place page fields and groups on the page. Similarly, in the actions section, you use these functions to place actions in the ribbon.

Function exampleApplies to...
addfirst(General)Groups only
addlast(General)Groups only
addafter(AddressDetails; "Post Code")Fields and groups
addbefore(AddressDetails; "Post Code")Fields and groups
movefirst(General)Groups only
movelast(General)Groups only
moveafter(AddressDetails; "Post Code")Fields and groups
movebefore(AddressDetails; "Post Code")Fields and groups

If you want to modify existing fields and groups on a page, you use the modify() function. See the code example below for syntax.

Snippet support :
Typing the shortcut tpageext will create the basic layout for a table object when using the AL Extension in Visual Studio Code.

Page Extension example :
The following page extension object extends the Customer Card page object by adding a field control ShoeSize to the General group on the page. The field control is added as the last control in the group using the addlast function. In the actions area, you can see what the syntax looks like for actions that execute triggers and actions that run objects.

pageextension 70000020 CustomerCardExtension extends "Customer Card"
{
    layout
    {
        addlast(General)
        {
            field("Shoe Size"; ShoeSize)
            {
                CaptionML = ENU='ShoeSize';

                trigger OnValidate();
                begin
                    if ShoeSize < 10 then
                        Error('Feet too small');
                end;
            }
        }

        modify("Address 2")
        {
            CaptionML = ENU='New Address 2';
        }
    }

    actions
    {
        addlast(Creation)
        {
            group(MyActionGroup)
            {
                Action(MyAction1)
                {
                    CaptionML = ENU='Hello!';

                    trigger OnAction();
                    begin
                        Message('My message');
                    end;
                }

                Action(MyAction2)
                {
                    RunObject = codeunit "Activities Mgt.";
                }
            }
        }
    }

   var
        Msg : TextConst ENU='Hello from my method';

    trigger OnOpenPage();
    begin
        Message(Msg);
    end;
}



Thanks & Regards,
Nandesh Gowda

Using the New Dynamics NAV In-Client Designer

Hi All,

Using the Dynamics NAV In-Client Designer

With the Dynamics NAV in-client designer, you can create extensions using drag-and-drop inside the client. With this preview of the in-client designer, you can:
  • Enter and exit design mode
  • Move fields around
  • Add existing fields
  • Preview your design (desktop, tablet, and phone preview)
  • Save the extension for the tenant
Adding a field

The in-client designer is switched on by choosing the design icon in the ribbon top right corner from any page that you want to make modifications to, and then choosing More.

In design mode you modify the current page; you can add existing table fields, move fields around, or remove fields from the page.




Note :
With this preview you can only add existing table fields. Adding pages, groups, parts, and actions is not yet supported.

Use the add field functionality to add a field to the page. You will get a pane to the right where you can see all of the table fields that are available for the specific page.

The table fields displayed are based on the underlying table or tables. The field can have a status of Placed, which means that the field already exists on the page.
A status of Ready means that the field doesn't already exist on the page, and that you can place it.

You can Remove field by clicking on any of the field on the page.




When you modify subpages on a given page, a square is displayed to mark the area that you can move a field within. This is also true for FactBoxes.




Change a FastTab caption by clicking the caption and start writing.



The display type icons let you preview the changes you made on desktop, tablet, and phone clients. This way you can make sure that your design will work on the intended display target(s).
You can flip to display tablet and phone designs in landscape as well.




All the UI changes are stored as Extensions.




Thanks & Regards,
Nandesh Gowda

Developing Extensions Using the New Development Environment Getting Started NAV

Hi All,

The Microsoft Dynamics NAV ‘Tenerife’ Developer Preview is still evolving with frequent update.

Extensions are a programming model where functionality is defined as an addition to existing objects and defines how they are different or modify the behavior of the solution.

Below link on MSDN section explains how you can develop extensions using the new development environment for Dynamics NAV.

https://msdn.microsoft.com/en-us/dynamics-nav/newdev-dev-overview.

For previous post on Extensions on my blog please refer below links.

https://nandeshgowda-navblog.blogspot.in/2016/11/extending-microsoft-dynamics-nav-using.html

https://nandeshgowda-navblog.blogspot.in/2016/11/developing-extension-package-nav.html


Here we will discuss on how to get started with the new Development Environment.

To get started writing extensions for Dynamics NAV you will need a Dynamics NAV tenant, and Visual Studio Code. Visual Studio Code is a cross platform editor that you will use for coding and debugging.

For the preview, you will download a VM from the Microsoft Azure Gallery which is set up for trying out the new development environment.
Steps :
1) First, you will need an Azure subscription. You can sign up for a free subscription.

2) Go to Microsoft Azure Marketplace and search for Microsoft Dynamics NAV Developer Preview. Then click on Create to create new Virtual Machine.



3) Fill in the various details and create a new virtual machine. It will take 10-15 mins to create the same.


4) Now connect to VM with the Login credentials given while creating VM.













5)  If you can't see Visual Studio Shortcut on Desktop, Open C:\Demo folder and run the script called Install New Developer Experience.ps1 and select Run with Powershell.























6) After Installing you can see the Visual Studio Shortcut on Desktop.



7) Now Open the New Visual Studio Code Editor




Thanks & Regards,
Nandesh Gowda

10 December 2016

The remote certificate is invalid according to the validation procedure SMTP NAV

Hi All,

The remote certificate is invalid according to the validation procedure

The above error may come while sending mails through SMTP in NAV.

The reason may be you have setup Secured Connection in SMTP setup in NAV, while the SMTP Server doesn't have valid certificate to accept the secure connection.

You can  install a valid certificate on Server or you can untick Secured Connection in SMTP setup to connect with unsecured connection.

Thanks & Regards,
Nandesh Gowda

There is a Communication protocol mismatch between the client and the server for NAV 2013 R2

Hi All,

There is a Communication protocol mismatch between the client and the server.

You may get above error while connecting to NAV RTC Client in NAV 2013 or NAV 2013 R2.

The error is due to the mismatch of Configuration Settings between ClientUserSettings.config file on Client with the NAV Server Instance Configuration Settings.

For Ex :  ClientServicesCredentialType is set to NavUserPassword on ClientUserSettings.config

and the Credential Type set on NAV Server Instance is Windows.


Thanks & Regards,
Nandesh Gowda

To add a Microsoft Dynamics NAV web server instance

Hi All, 

To add a Microsoft Dynamics NAV web server instance

1) On the computer or virtual machine that is running Microsoft Dynamics NAV Server, run Microsoft Dynamics NAV Administration Shell as an Administrator.

  • Choose Start, in the Search box, type Microsoft Dynamics NAV Administration Shell.
  • Right-click the related link, and then choose Run as Administrator.
2) At the command prompt, type the following command:

New-NAVWebServerInstance -WebServerInstance -Server -ServerInstance -ClientServicesCredentialType

Specifies the name that you want to give the Microsoft Dynamics NAV Web client application instance. This name will become part of the URL for the Microsoft Dynamics NAV Web client application, for example, http://MyWebServer:8080/MyWebApp/WebClient.

Specifies the name of the computer that is running the Microsoft Dynamics NAV Server to connect the Microsoft Dynamics NAV web server to. 

Specifies the name of the Microsoft Dynamics NAV Server instance to connect the web server instance to. 

Specifies the credential type that is configured for the Microsoft Dynamics NAV Web client and Microsoft Dynamics NAV Server. Valid options are NavUserPassword, Windows, UserName, and AccessControlService. The default value is NavUserPassword.
Note :
The command that is shown includes only the required parameters of the NAVWebServerInstance cmdlet. The cmdlet has several other parameters that can be used to configure the web server instance. 

3.Press Enter to run the cmdlet.

A new Microsoft Dynamics NAV web server instance with the specified name is added to the Microsoft Dynamics NAV Web client site on IIS

If you want to change the configuration of the new Microsoft Dynamics NAV web server instance after it has been added, modify the web.config file. 


Thanks & Regards, 
Nandesh Gowda


A fatal error occurred. The connection to SQL server cannot be established NAV

Hi All,

When you try to open Microsoft Dynamics NAV Web client, you get the following error:

A fatal error occurred. The connection to SQL server cannot be established or is no longer usable.

There can be various causes of this error. The most common causes are that Microsoft Dynamics NAV Server has stopped or the connection to SQL Server is not configured correctly.

Resolution :

1) Microsoft Dynamics NAV Server connects to the correct database by using the correct login account. You can verify this by using the Microsoft Dynamics NAV Server Administration tool.


2) Login account has the following permissions:



  • Set up as a user in the Microsoft Dynamics NAV database on SQL Server with the following role memberships: db_datareader, db_datawriter, and db_ddladmin. 

3) SQL Server has the following configurations:

  • TCP/IP protocol is enabled.
  • SQL Server executable file is allowed through the Windows Firewall.


  • SQL Server Browser Service is running. This is required only when Microsoft Dynamics NAV used a named database instance, such as NAVDEMO, and Microsoft Dynamics NAV Server is on a different computer than SQL Server. 

For more information, see Troubleshooting: SQL Server Connection Problems.


Thanks & Regards,
Nandesh Gowda

A server error occurred and the content cannot be displayed NAV Web Client

Hi All,

When you try to open the Microsoft Dynamics NAV Web client, you get the following error:

A server error occurred, and the content cannot be displayed. Refresh the page or open a new browser window.

In the Event Viewer of the computer that is running Microsoft Dynamics NAV Web Server components, the Windows application log includes the following event:

Message: A server was not found at “net.tcp://navserver:7046/DynamicsNAV71/Service”. Either the URL is incorrect or the server is currently not available. 

This error occurs when the Microsoft Dynamics NAV Web client cannot connect to Microsoft Dynamics NAV Server. 

To resolve this error, verify that the following conditions are met:

• The Microsoft Dynamics NAV Web client is configured to connect to the correct Microsoft Dynamics NAV Server. Also please check the Server Instance, Port No.,Credential Type,etc and other configuration settings in Web.Config File.

• The logon account of Microsoft Dynamics NAV Server has permission to log on as a service on the computer that is running Microsoft Dynamics NAV Server.

• If you are using Mozilla Firefox as your browser, then you must enable cookies in the browser. Additionally, configure the address of the Microsoft Dynamics NAV Web client as a trusted URI in Firefox. For more information, see How to: Configure Mozilla Firefox for Microsoft Dynamics NAV Clients.

• If IIS and the Microsoft Dynamics NAV Server are on separate computers, verify the following conditions:

1) If the Microsoft Dynamics NAV Web client is using Windows authentication, then the Negotiate provider must be included at the top of the providers list in the Windows authentication setup in IIS. For more information, see Configuring the Credential Type on the Microsoft Dynamics NAV Web Client Website.

2) Delegation is configured from the computer that is running IIS to the computer that is running Microsoft Dynamics NAV Server, including the following:

  • Kernel mode authentication is either disabled or configured to use the service account of Microsoft Dynamics NAV Server (Microsoft Dynamics NAV Web client only).
  • The following Service Principal Names are registered for the logon account of Microsoft Dynamics NAV Server:

DynamicsNAV/navserver:port

DynamicsNAV/navserver.domain:port

If you still get this error after verifying the setup, then disable the Use Kerberos Only option in the delegation setup and try again. The Use Kerberos Only option does not work on some network configurations with Microsoft Dynamics NAV.


Thanks & Regards,
Nandesh Gowda

16 November 2016

Developing Extension package NAV

Hi All,

Please refer my previous post on Extensions Overview.
https://nandeshgowda-navblog.blogspot.in/2016/11/extending-microsoft-dynamics-nav-using.html

Today we will discuss on how to develop & use Extensions.

We can build extension packages that add functionality to a Dynamics NAV deployment. Unlike the familiar development and deployment of Dynamics NAV functionality, building an extension relies on the exported version of an application to .TXT files.

We can export the application from the development environment, use the development environment commands, or use the Windows PowerShell cmdlet that is available in the Microsoft Dynamics NAV 2017 Development Shell, Export-NAVApplicationObjectLanguage.

I will create a new field on Customer table and put some validation on that field using Events.

Please refer my below post on how to implement Events
https://nandeshgowda-navblog.blogspot.in/2016/09/implementing-events-in-nav-2016.html


1) To start with please create a folder structure similar to below so that while creating a extension package we can use below path for Cmdlets for converting/merging and creating delta.



2)  The foundation for our extension is the exported .txt files of the objects we are modifying. We can export just the objects that we want to modify, or we can export the entire Dynamics NAV application. We can use  Export-NAVApplicationObjectLanguage cmdlet to export the objects.




3) Now we need to create a functionality using Events, In my example I have just added a field in Customer table and added a validation on onBeforeValidateEvent of new field created. I have used Events for the code changes.



4)  Write extension upgrade code for new or modified tables. This is needed as we may get error while building the Extensions. For time being you can just create upgrade codeunit and add the functions in it.

To write upgrade code for an extension

Create new codeunit.

Important

This must be a codeunit of type Normal, not an Upgrade codeunit.

Add upgrade functions to the codeunit. Make sure the function is declared as global so that the Local property is set to No.

Add the OnNavAppUpgradePerDatabase() function if the extension contains cross-company tables.

Add the OnNavAppUpgradePerCompany() function if the extension contains per-company tables.




5)  Now I will verify whether the changes are working from RTC Client.




6) Now Export the Modified objects in text format.




7) Our delta files must be one-to-one with the objects we have added or modified.

We cannot include a single merged delta file. If we output our export file as a single file use the Split-NAVAppplicationObjectFile cmdlet to create the individual files.

Go to  "Microsoft Dynamics NAV 2017 Development Shell" and type the command to split the file into individual objects





8) Create DELTA files using the Microsoft Dynamics NAV 2017 Development Shell cmdlets.

Extension packages are based on application object deltas. Again, we use the application merge utilities in the Microsoft Dynamics NAV 2017 Development Shell to distill the changes in the form of application object differences that are stored in DELTA files.

We use the Compare-NAVApplicationObject cmdlet to create these delta files.



If we will be adding Multilanguage translations for captions or constant. Use below cmdlet.

Compare-NAVAppApplicationObjectLanguage -OriginalPath MLORIGINAL -ModifiedPath MLMODIFIED -DeltaPath MLDELTA

9) Build Extension package.

Use the New-NAVAppManifest and New-NAVAppPackage cmdlets to build the manifest and package file.

The following is an example of how to create a new extension .NAVX package file with a new manifest.




10)  Signing a NAVxfile.

Code signing is a common practice for many applications. We must have a certificate on the computer (as a file or in the certificate store) that includes code signing for the intended purpose.

It is recommended that we use a certificate from a third party certificate authority. For testing purposes, it is acceptable to create a self-signed certificate using the New-SelfSignedCertificate cmdlet in PowerShell on Windows 10 or MakeCert.

I will Skip this process of Signing in this Demo. We will use unsigned extension package to Publish and Install.


11) Publish and Install extension :

We have packaged our extension so it is ready to be published and installed on a target server.

Please take a new & clean database without any customisations done to publish and install the extensions.

Use Publish-NAVApp cmdlet to publish the Extension for the service Instance



To Install we can use Install-NAVApp cmdlet

Install-NAVApp -ServerInstance YourDynamicsNAVServer -Name ”My Extension” –Tenant Tenant1, Tenant3

OR

We can install the same from RTC NAV Client

Go to Extension Management and install the published extension in our case FOCCustomer.



Now after installing we can verify whether our changes are reflecting on customer card.





NOTES :

1) Objects must be exported as .TXT files. We cannot build an extension based on a .FOB file.

2) DO NOT make C/AL code modifications.

3) DO use subscribing to events to execute code.

4) DO NOT change restricted page and table properties.

5) The packaging process adds a description of the extension to the manifest, such as whether it changes pages or adds tables. While not explicitly being enforced currently, this can be used to determine whether to install an extension, or not.

6) If we want to publish an unsigned extension package, we need explicitly state that by using the –SkipVerification parameter on the Publish-NAVApp cmdlet.

7) When we install an extension that includes changes to the menu suites, this does not take effect for any user until we sign out and then sign in again.



Please refer below MSDN links for Extensions

1) Developing Extensions for NAV 2017
https://msdn.microsoft.com/en-us/dynamics-nav/how-to--develop-an-extension

2) Create an Extension package for NAV 2017
https://msdn.microsoft.com/en-us/dynamics-nav/how-to--create-an-extension-package

3) Publish and Install Extension for NAV 2017
https://msdn.microsoft.com/en-us/dynamics-nav/how-to--publish-and-install-an-extension

4)  How to Write Extension Upgrade Code for NAV 2017
https://msdn.microsoft.com/en-us/dynamics-nav/extensions-upgrade-howto

5)  Extension Packages Capability Support Matrix for NAV 2017
https://msdn.microsoft.com/en-us/dynamics-nav/extension-packages-capability-support-matrix


Thanks & Regards,
Nandesh Gowda

Extending Microsoft Dynamics NAV Using Extension Packages

Hi All,

You can extend and customize a Dynamics NAV deployment without modifying the original application objects. With extension packages, you install, upgrade, and uninstall functionality in on-premises deployments or for select tenants in a multitenant deployment. Customers can easily add or remove horizontal or customized functionality to their solution that upgrade much easier than past solutions.

The main difference from classical development is that source code modifications are not allowed. Instead, you use C/AL events to extend and customize objects.

Extensions are delivered as .navx package files. A .navx package contains the various artifacts that deliver the new functionality to the Dynamics NAV deployment as well as a manifest that specifies the name, publisher, version, and other attributes of the extension. You manage .navx packages with a series of Windows PowerShell cmdlets that are available in the Microsoft Dynamics NAV 2017 Administration Shell. There are also cmdlets available to ISVs and developers in the Microsoft Dynamics NAV 2017 Development Shell that help create packages.


How Extensions Work

Extensions are in the simplest terms the runtime application of objects and object deltas for a specific combination of an extension package and a tenant. When an extension is published to a Dynamics NAV deployment, it compiles the objects in it against the current application database. Then, when the extension installs for a tenant, it stores the association and builds the relevant database schema. At runtime, Dynamics NAV simply loads the associated objects for that extension and tenant.

You can publish multiple extensions to a Dynamics NAV deployment and, in multitenant deployments, install any combination of published extensions for each tenant. For example, consider a scenario with a multitenant deployment with extensions A, B, C, and D published to it. Each tenant can have their own unique combination of extensions. So tenants 2, 3, and 4 can have the same extensions (extensions B and C) while tenants 1 and 5 only have one extension each, extension A and D, respectively. This provides for a great degree of customer functionality choice while at the same time maximizes the server hardware and administration workload.

In most cases, two extension packages can coexist and work independently of each other; however there is the possibility that two apps will try to modify the same object properties. In those cases, if the conflict cannot be resolved, the installation of the conflicting extension fails.


You can refer below MSDN Link for detailed explanation about Extensions.

https://msdn.microsoft.com/en-us/dynamics-nav/extending-microsoft-dynamics-nav-using-extension-packages


As per my understanding we will have a dilemma whether to go for extensions or use the traditional development methods.

We can have below consideration while choosing Extensions :

1) Is the database going to be heavily customized or not?

2) Is the development done can be easily maintained and monitored?

3) How frequently the changes will come in your existing extensions ?

4) What  level of IT hardware & Configuration needed for extension?

5) More the extensions used, more consideration to be given for Server hardware configuration as the extensions will be loaded by NAV at run time.

6) Upgrade Flexibility

7) Multi Tenant Environment Flexibility

8) Using extensions for third party App, ISV, etc.


Anyways we need to move forward and start using Extension packages for most of our developments.
.
I feel in future Extensions will be heavily concentrated on and improvements will come in this regard. As its obvious from NAV 2016 and NAV 2017 releases and changes w.r.t to Extensions.


Thanks & Regards,
Nandesh Gowda

Cannot add the Field Trigger or cannot add variable NAV Extensions

Hi All,

Cannot add the Field Trigger to.

Above error may come when creating Extension package using New-NAVAppPackage cmdlet.

The above error may come if you have written some code on Triggers of page or table for a field.

So please remove the code and use the Events to implement your code.

We have default trigger events available for table or page to write our code on when you subscribe to table/page object.

Cannot add variable to

Again this is similar kind of error, please remove the variable defined from the object and implement the logic using Events.

Thanks & Regards,
Nandesh Gowda

Publish-NAVApp : Merge Conflict: Could not update Codeunit NAV Extensions

Hi All,

Publish-NAVApp : Merge Conflict: Could not update Codeunit XXXX

Above error may come while using Publish-NAVApp cmdlet, if the customized objects which are added for development are already available in NAV Database.


Thanks & Regards,
Nandesh Gowda

09 November 2016

Account Categories and Account Subcategories on Chart of Accounts NAV2017

Hi All,

New fields have been added on chart of accounts for categorization of Accounts.

To start with we will discuss G/L Account Category

NAV 2017 comes with five predefined Account Category.

You can add new Subcategories from G/L Account Category Page. Basically Account Subcategories are grouping under Account categories.

You can use Generate Account Schedules that will update predefined financial reports such as Balance Sheet, P&L, etc. ( through Account Schedules).




On Chart of Accounts you can see Account Category field with five predefined values

Account Category : 



Account Subcategory :

It's a variable on G/L Account Card.

It's value is picked from G/L Account Category based on the Account category selected.



Benefits of using Account Categories :
  • Various Financial Reports (Balance Sheets, P&L, etc.) are readily available from Account Categories.
  • We can group the G/L Accounts into Categories for better user understanding.
  • We can see balances as per Categories and Subcategories.
  • We can use the Categories for developing various kinds of Analysis reporting.


Thanks & Regards,
Nandesh Gowda

Notifications in UI NAV 2017

Hi All,

Notifications provide a programmatic way to send non-intrusive information to the user interface (UI) in the Dynamics NAV Web client. Notifications differ from messages initiated by the MESSAGE function. Messages are modal, which means users are typically required to address the message and take some form of corrective action before they continue working. On the other hand, notifications are non-modal. Their purpose is to give users information about a current situation, but do not require any immediate action or block users from continuing with their current task. For example, you could have a notification that a customer's credit limit is exceeded.


Notifications in the UI :

In the UI, notifications appear in the Notification bar (similar to validation errors) at the top of the page on which a user is currently working. The user can then choose to dismiss the notification, which clears it. Or if actions are defined on notification, the user can choose one of the actions.

  • There can be multiple notifications. The notifications appear chronological order from top to bottom.
  • Notifications remain for duration of the page instance or until the user dismisses them or takes action on them.
  • Notifications that are defined on sub-pages, for example in parts and FactBoxes, appear in the same Notification bar.
  • Validation errors on the page will be shown first.

Notifications in the development environment :

By using the Notification and NotificationScope data types and functions in C/AL, you can add code to send notifications to users. The following table provides an overview of the available functions. The sections that follow provide additional information about how to create notifications.


FunctionDescription
MESSAGESpecifies the content of the notification that appears in the UI.
SCOPESpecifies the scope in which the notification appears.
SENDSends the notification to be displayed by the client.
ADDACTIONAdds an action on the notification.
SETDATASets a data property value for the notification
GETDATAGets a data property value from the notification.
RECALLRecalls a sent notification.

Creating and sending a notification:


You create a notification by using the MESSAGE and SEND functions. The MESSAGE function defines the message part of the notification. When the SEND function is called, the notification is sent to the client and content of the message is displayed.
MyNotification.MESSAGE := 'This is a notification';
MyNotification.SEND;
The SEND function call should be the last statement in the notification code, after any ADDACTION or SETDATA function calls for the notification instance.

Defining the notification scope :

The scope is the realm in which a notification is broadcast in the client. There are two different scopes: LocalScope and GlobalScope.
  • LocalScope notification appears in context of the user's current task, that is, on the page the user is currently working on. LocalScope is the default.
  • GlobalScope notification is not directly related to the current task. Note:GlobalScope is currently not supported, so do not use it. This will be implemented in a future release.
The following code creates a notification in the LocalScope:
MyNotification.MESSAGE := 'This is a notification';
MyNotification.SCOPE := NOTIFICATIONSCOPE::LocalScope;
MyNotification.SEND;

Adding actions on a notification :

You add actions on notifications by using the ADDACTION function. This function provides a way for you to create interactive notifications. By default, users have the option to dismiss the notifications. However, there might be cases where you want to provide users with different actions that they can take to address the notification, like opening an associated page for modifying data.
Conceptually, a notification action calls a function in a specified codeunit, passing the notification object in the call. The function includes the business logic for handling the action.
MyNotification.MESSAGE := 'This is a notification';
MyNotification.SCOPE := NOTIFICATIONSCOPE::LocalScope;
MyNotification.ADDACTION('Action 1',CODEUNIT::"Action Handler",'RunAction1');
MyNotification.ADDACTION('Action 2',CODEUNIT::"Action Handler",'RunAction2');
MyNotification.SEND;
The basic steps for adding an action are as follows:
  1. Create a global function in a new or existing codeunit. The function must have a Notification data type parameter for receiving the notification object.
  2. Add C/AL code to the function for handling the action.
  3. Specify the codeunit and function in the ADDACTION function call.
Important
You can have more than one action on a notification. A LocalScope notification can have up to 3 actions. A GlobalScope notification can have up to 2 actions.

Sending data with a notification :


You use the SETDATA and GETDATA functions to add data to a notification, which is typically needed when actions are invoked. The SETDATA function sets, or adds, data to the notification. The data is defined as text in a key-value pair. With the GETDATA function, you can then retrieve the data again.
The following code sets data for a notification:
MyNotification.MESSAGE := 'This is a notification';
MyNotification.SCOPE := NOTIFICATIONSCOPE::LocalScope;
MyNotification.SETDATA('Created',FORMAT(CURRENTDATETIME,0,9));
MyNotification.SETDATA('ID',FORMAT(CREATEGUID,0,9));
MyNotification.ADDACTION('Action 1',CODEUNIT::"Action Handler",'RunAction1');
MyNotification.ADDACTION('Action 2',CODEUNIT::"Action Handler",'RunAction2');
MyNotification.SEND;
The following code gets the data for a notification:
DataValue := MyNotification.GETDATA('Created');
DataValue := MyNotification.GETDATA('ID');
Example :


This simple example illustrates how notifications work and provides some insight into how you can use them. This example uses page 42 Sales Order of the CRONUS International Ltd. demonstration database according to the following.
  • The code compares a customer's balance with their credit limit. If the balance exceeds the credit limit, a notification is sent to the client.
  • The notification includes an action, which has the caption Change credit limit, that opens page 21 Customer Card. This enables the user to increase the credit limit.
To complete the example, follow these steps:
  1. In C/AL code for page 42 Sales Order, add the following variables and text constants:
    Variable NameData TypeSubtype
    CustomerRecordCustomer
    CreditBalanceNotificationNotification
    OpenCustomerText
    Text Constant NameConstValue
    Text003The customer's current balance exceeds their credit limit.
    Text004Change credit limit
  2. Add the notification code on page 42 Sales Order.
    For this example, add the code on OnOpenPage tigger in C/AL .
  3. Create a codeunit, called Action Handler, for handling the notification action as follows:
    • Add a global function called OpenCustomer that has a Notification data type parameter called CreditBalanceNotification for receiving the Notification object.
    • Add the following C/AL variables to the codeunit:
      Variable NameData TypeSubtype
      CustNumberText
      CustNoText
      CustRecRecordCustomer
      CustPagePageCustomer Card
    • Add the following code to the OpenCustomer function:



Thanks & Regards,
Nandesh Gowda