Saturday, October 27, 2018

Dynamics 365 Business Central: handling breaking schema changes on production

Hello Friends,
I saw many requests on forums in the last days related to one of the most noisy topic when working with Extensions in Dynamics 365 Business Central (SaaS version): how to handle breaking schema changes.
The tipical scenario is the following:
  1. You create an extension (version 1.0) that contains a custom table with some fields and some keys and publish it. All is ok.
  2. Then, you create a new version of the same extension (2.0) where you change some field data types (or some field properties) or you change some table’s keys.
  3. You publish the new 2.0 version and…
ERROR: “Unsupported table change” message or (for keys) the message is something like “An unsupported key change was detected. Keys cannot be changed, removed, or reordered. New keys can only be added to the end of the list“.
Previously (in the C/AL era) if you change a field property on a table or if you change a table’s key and you’re sure that this will not occour in a data loss, you could export the fob and import them in the production environment using the force option and all works.
Now in the cloud environment things are different.
Extensions V2 do not support breaking schema changes across synchronized versions of the extension. Uninstalling and unpublishing the 1.0 extension will not remove the schema elements coming from an extension.
In your local sandbox environment you can “clean” your environment in the following ways:
  • From Visual Studio Code by using “schemaUpdateMode”: “Recreate” in launch.json
  • From Powershell by executing the following command:
Sync-NavApp -Name <name of extension> -Version <Version of extension> -Tenant <Tenant name> -Mode Clean
This will remove all the schema elements across all versions of the extension (and also all the data). The next time you will deploy your extension, the system will not found an “old schema” to compare agains the new schema and all your changes will be considered as new.
What about in the production environment?
In a production environment, once an extension is synchronized to a tenant then all the next versions (upgrades) must have a schema that is backward compatible. To handle this scenario (that can occour, I agree…) you can:
  1. Mark the changed field with ObsoleteState = Pending or Removed.
  2. Create a new table (or new fields or keys) with the new data type or values.
  3. Create an Upgrade codeunit that moves the old data to the new data.
  4. Use the new field or keys.
The ObsoleteState can have these values:
  • Pending: the element will be obsolete in a future release. This setting has no effect on the current use of the table, field, or key in code.
  • Obsolete or Removed: the element is not deleted from the database; however, references to the the element in code are only allowed in upgrade codeunits. References from other objects will result in a runtime error.
If you need to change a primary key of a table from a previously deployed 1.0 extension, I think the best way is to create a new table and mark the old table as obsolete. In your Upgrade codeunit, move the data from the old table to the new table.
Lesson learned after this post? That in the SaaS era, you have to deploy in a production environment more and more carefully than before and only when your design is really ready!

Sunday, October 21, 2018

Field can appear only once in table Dynamics 365 Business Central

Hello Friends,

If you try to add new field using table extension and field already exists in standard table by other installed extension or manual created in standard table using developer environment (on-prime). 

tableextension 50001 CustomreExt extends Customer
field(50000; "Field From BC"; Integer)
DataClassification = ToBeClassified;

myInt: Integer;

When you publish than extension than system give error failed with code 422. Reason:
The field ID '50000' can only appear once in the table 'Customer'

In this case we already created field using development environment (on-prime D365 BC)

Error coming at publishing of extension,

Thank you for reading...
Write a comment if you have any concern.

Saturday, October 20, 2018

Publish One More D365 Business Central Extension in App Source - Product Catalogue

Hello Friends,

Me and my team at Intech-Systems, Publish one more extension in App Source for Dynamics 365 Business Central,

It was very good experience to working with App Source Team for multiple email conversion and correction in app to qualifying it for publish on app source.

Product Catalogue

Intech Systems Pvt Ltd.

Click here to view it on app source - App Source Link

Product Catalogue App provides an easily way to configure the Items on the Sales Document.
In a business system, every item is defined with a unique code so there wouldn't be any conflict between the items. While creating a Sales Quote or a Sales Order document, you will need to enter the Item Code in Sales Line. If yours is a small business, you might remember every item code in detail but if yours is a big company with many products, it is difficult to remember all the codes. In this situation, you will have to open the item codes' list and search for the required Item Code.
Product Catalogue App helps you solve the above issue. With this App, you don't have to remember all the item codes. You have to categorise the Items into the following three categories.
  • Product: Product is the first main group to add Main Product details.
  • Category: Category is the second group to add the sub details of Product.
  • Model: Model is the third group to add the sub details of the Category Group.
  • Easily Manage the Items based on the Product, Category and Model No. wise.
  • Provides an easy way to assign Items on Sales Quote and Sales Order.
  • Configure the Suggested Items for specific Items.
  • User can easily filter and search the Items based on the Product, Category and Model wise.
  • In big organization, it is easily to review Item based on Product, Category and Model wise.
  • While assigning Items on Sales Quote and Sales Document, we can easily identify and select Items based on the Product, Category and Model wise.
  • It reduces the time and increase the efficiency for Sales Document Transactions.
Try this app now for less complexity, more automation and seamless process. No hassle of remembering codes or keeping a track of all the codes, thus increasing productivity.
This extension supports both the Essential and Premium edition of Microsoft Dynamics 365 Business Central. This extension is available in the United States.

Table Trigger available with extended table and sequence of execution

Hello Friends,

With new version of AL Code, Now the table base trigger available with extended tables and we can use it as normal table trigger.

The tableextension object has four new triggers:
  • OnInsert
  • OnModify
  • OnDelete
  • OnRename

What are these triggers and how are they related to the OnInsert / etc. triggers in the base table? And what’s the difference with the already existing OnBefore and OnAfter triggers in the tableextension object?
The difference is that these new triggers will be executed before the data of the table has been written to the database. While the OnAfter triggers will be executed after the data has been written to the database.
Table extension trigger execute before the table trigger.
With so many triggers and events, I thought it would be a good idea to compose a list with the correct order in which they are executed. So here is a table for the database insert (same applies to modify, delete and rename of course):

Thank you reading,
Let write in comments if you want to know more detail.

Thursday, October 18, 2018

Develop First VS Code Extension with D365 Business Central On-Prime Version

Hello Friends,

Let jump into future of development with VS Code,

This blog will help you to configure your first AL Language extension with D365 Business Central On-Prime Server.

Step 1 - Download and install D365 Business Central On-Prime Version.
             You can download from this link

Step 2 - Download and install VS Code from link -
              After that, install latest AL Language extension in VS Code.

Step 3 - Make sure that you are able to run web client of D365 BC on-prime version and base URL setup correctly in configuration file.

D365 BC On-Prime Database and Server Instance Detail

Business Central Web client working properly.

Configure "Web Client Base URL" (PublicWebBaseUrl) in service to avoid error during publish vs code extension (Could not open the specified startup page. Please check that the server configuration key PublicWebBaseUrl has been properly set)

Step 4 - Start the VS Code and go to command plate to create new projects,
              Write AL!GO on command plate to create new project.

Go to command palette from View >> Command Pallet (short cut key - Ctrl + Shift + P or F1)

write AL:Go!  to create new AL Language extension project

Write the name of project at end.

Step 5 - System will default create the app.json and launch.json files, configure your op-prime business central service in lanuch.json file as shown in following snapshot.

Default files create with new project

app.json file contain the detail about id, app name and object range details.

launch.json contain the detail about configure business central service detail to start your project with link service while pressing F5 / Ctrl + F5 and also require to download symbols.

Step 6 - Download the base business central object (symbols) from link server in launch.json file.
              Go to command plate and write AL!Download Symbols

After successfully download symbols, system will show following message.

Step 7 - Now the all setup completed and we are ready publish our first Hello World ! extension in on-prime D365 Business Central.

Press F5 publish your first extension on link server.

Very useful AL Command keyboard shortcut to remember for developer

Keyboard Shortcut Action
Ctrl+Shift+P Show All Commands
Ctrl+F7 Download source code
Alt+A Alt+L Go! Generates a HelloWorld project
Ctrl+Shift+B Package
F5 Publish
Ctrl+F5 Publish without debugging
F6 Publish and open the designer
Ctrl+F2 Update the compiler used by the service tier(s)

Tips - Step the "NetFx40_LegacySecurityPolicy" parameter to false in "Microsoft.Dynamics.Nav.Server.exe.config" file to avoid error in publish extension from VS Code.

You can find config file from path.

Set enabled = false in setting and restart the service to take effect.

I hope this blog help someone to setup there first extension development

If you need any help than write in comments.

Thank you for reading.
Keep Sharing...Keep Growing...

Modify Standard Pages Control Using Extension in Business Central

Hello Friends,

Get ready for new future for development skills with Dynamics Products.
As you know, in Business Central we can't modify the base systems standard objects,
Only way to modify base is to create extended object and event subscription.

Suppose you want to modify standard page field property, than you need to create the page extension of standard page and can add, delete, modify fields and property and action of standard page.

AL Language provide us new functions Modify(), Addafter(), functions for modify standard pages.

Following are list of property for page field and action that we can modify using Modify() function in page extension.

pageextension 70144473 pageextension50001 extends "Sales Order"
            Visible = false;
            part(Complaint; "INT Complain Register Subform")

            Visible = false;

Hope it will help someone to understand the concept of development with AL Language using VS Code.

Please write a comment if you need more help,

Thank you for reading,
Keep Sharing....Keep Growing ......

Wednesday, October 17, 2018

Which object ranges can we use with Microsoft Dynamics 365 Business Central?

Hello Friends,

I wanted to provide some clarity on how you want to think about object ranges in Dynamics NAV and Microsoft Dynamics 365 Business Central.  Which object ranges are used for what, which one have potentially costs associated, how do you apply for them and what changed with the launch of Business Central.  Let me know in the comments if you have questions on this topic.

0 – 49,999: The Business Central base application

This range is assigned for the Business Central base app functionality.  Not to be used by partners!

50,000 – 99,999: Customization ranges

This object range is designed for resellers who want to customize the delivered solution to individual needs of a customer.
When implemented with Dynamics NAV On-Premise, partner hosted or Azure IAAS:
The objects in this range needs to be purchased from the Dynamics Pricelists when implemented on premise, partner hosted or Azure IAAS. They are implemented in the traditional way using C/Side or through loading extensions.
When implemented with Dynamics 365 Business Central On-Premise, partner hosted or Azure IAAS:
The objects in this range needs to be purchased from the Dynamics Pricelist when implemented on premise, partner hosted or Azure IAAS. They are implemented in the traditional way using C/Side or through loading extensions.
New since fall 2018 (Cumulative Update 1 - planned for November) The extension objects developed in AL and stored in the 80,000 – 99,999 range which extends objects to which you have modify permissions in your development license.   (For ex.  When you want to extend the Customer table from the base app, you are required to develop an extension object and assign a unique object ID to it – this is now for free in this specific customization range).
When implemented in Dynamics 365 Business Central SAAS:In the SAAS service, customizations are build in Visual Studio Code and AL against a sandbox environment or a Docker contrainer and loaded in the tenant through tenant customizations.  The objects in this range are currently free of charge.  Expect that customizations in the SAAS service will be monetized at some point in time.

1,00,000 - 9,99,999: Localization range

The objects in this range are mainly designed when the Microsoft team localizes Dynamics 365 Business Central for a specific country or region.
These objects cannot be used by partners.

1,000,000 – 69,999,999: Registered Solution Program (RSP) range

This range is designed for your unique horizontal or vertical niche solutions which you will implement repeatedly .  When you apply for a RSP solution, a unique range will be assigned to your solution by Microsoft. Terms in The RSP program details determine whether you need to pay quarterly fees.
However, if you comply with the ‘Certified for Microsoft Dynamics’ (CFMD) program requirements, one of the benefits of the program is that the quarterly fees on object costs will be waived. 
New since summer 2018, Next to be able to implement these solutions on-premise, partner hosted or on Azure IAAS in Dynamics NAV and Business Central on-premise, these modules can also be implemented in Business Central SAAS and Microsoft AppSource.  You will use the AppSource submission process for submitting.

70,000,000 – 74,999,999: Business Central apps

The objects in this range are designed for developing Apps for Business Central SAAS which are made available through Microsoft AppSource.   The code is developed in AL language using Visual Studio Code.  The objects created in the app are free of charge! You request those object ranges here
These Apps can be submitted through the AppSource submission process.
New since fall 2018 (Cumulative Update 1 - planned for November):  The apps, developed in this range and in AL can also be implemented in Business Central on-premise, partner hosted or Azure IAAS solutions.  The benefit here is that you don’t need to maintain multiple object ranges.