Development Tips

Automatic Deployment of Microsoft .NET Framework Interoperability and Control Add-in Assemblies

Microsoft Dynamics NAV 2015 makes it easier for the system administrators to deploy client-side assemblies for .NET Framework interoperability and client control add-ins on computers that are running the Microsoft Dynamics NAV Windows client or Microsoft Dynamics NAV Development Environment.

You can now install the assemblies in the Add-ins folder on the computer that is running Microsoft Dynamics NAV Server. By default, this is the C:\Program Files\Microsoft Dynamics NAV\80\Service\Add-ins folder.

When an operation from the client requires an assembly, Microsoft Dynamics NAV Server automatically deploys the assembly to a temporary folder on the client computer.

For example, if Microsoft Dynamics NAV Windows client opens a page that contains a control add-in, Microsoft Dynamics NAV Server will find the control add-in assembly by name in the Add-ins folder. Then, it deploys the assembly to the client computer in the %TEMP%\Microsoft Dynamics NAV\Add-Ins folder of the user who is running the client. Subsequently, the deployed assembly will be used whenever the page is opened.

Similarly, if the development environment requires a control add-in, for example, when you compile an object, then the control add-in assembly will be deployed by the Microsoft Dynamics NAV Server to the local temporary folder for the current user on the computer that is running the development environment.

Important:

To be deployed, an assembly must comply with the following Microsoft Dynamics NAV Server configuration settings: Chunk Size, Max Upload Size, and Prohibited File Types.

If a .NET Framework interoperability or control add-in assembly is updated and its version number changes, Microsoft Dynamics NAV Server will deploy the updated assembly to the client computer the next time that the client requests the assembly. The updated assembly is put in a subfolder of the %TEMP%\Microsoft Dynamics NAV\Add-Ins folder, where the subfolder has the assembly’s version number as its name. This implementation means that you do have to remove the older versions of assemblies that are stored on the client computer.

To support compatibility with earlier version of Microsoft Dynamics NAV, before Microsoft Dynamics NAV Server deploys an assembly to a client, the client looks for the assembly in the local Add-ins folder (for example, C:\Program Files (x86)\Microsoft Dynamics NAV\80\RoleTailored Client\Add-ins). If the assembly is not found, then the client will request the assembly from Microsoft Dynamics NAV Server.

Javascript-based client add-ins have been using this deployment technique since Microsoft Dynamics NAV 2013 R2.

Batch Job, Development Tips, Functional Tips

Adjust Item Costs/Prices… batch job

Just purchase one material on different rates with different vendors and consume it in manufacturing or do the negative adjustment and then run the batch job to see the effect.

The batch job is in the inventory section of Finance Module.

BatchJob-1
All this Batch does is updating the CARD Costs and Prices for an Item; it really has no connection to the costs posted to inventory, and in terms of Sales only affects the default sales price of an item. A better name might be “Item Card Cost/Price Update”
BatchJob-2
To test an example, run the batch on a test database, leave the defaults, but change the Adjustment factor to 1.1.
BatchJob-3
When you run this, all the Item Card Prices will be increased by 10%
BatchJob-4

Most of the processes relating to costing, discuss posted documents and entries. Like Posted Sales Invoice and Posted Purchase receipt and Item ledger entry and Value Entry and General Ledger and GL entries. All these tables (and others) are used to calculate the actual costs and prices in Navision, and are what is used for Accounting reporting such as financial Statements. This is all covered under Inventory Costing. The batch processes (periodic Activities) “Post Inventory Cost to G/L” and “Adjust Cost – Item Entries” all belongs in this category. But on the other side BEFORE you post anything you need to do setup, and amongst all the setup, are the fields on the Item card which ARE NOT POSTED to the GL, but are used as the default values before posting. For example Unit Price from the Item card is copied into the Line of a Sales Order as a SUGGESTED sales price. But you can change it here and post a different price. Most of the numbers that you see on the Item card are just defaults or suggestions; they are not the final number that is posted to the GL. All of this is covered by Inventory Setup, and includes the Batch Process “Adjust Item Costs/Prices”.

If you check the code you will find that:
BatchJob-5
In summary

Inventory Setup is what you do to setup Item Costs and Prices BEFORE they hit the GL. (including “Adjust Item Costs/Prices”). Inventory Costing is what you do with entries AFTER they are posted to correct any changes due to the difference between Expected costs and actual costs.
Just go through these steps and you will know what this batch job does-

1. Create a new Item. Complete all the fields with Unit cost and Unit price. Take a note of all the values you write.

2. Create a purchase order for any quantity with Unit cost other than what is on item card and post the order as received & invoiced.

3. Create a sales order with any quantity other than that of Item card and post as shipped and invoiced.

4. Check the invoicing tab on item card and make a note of all values.

5. Repeat steps 2 and 3 for two-three times by changing the cost and prices every time (also note the values)

6. Now run Adjust cost-item entries and check the Invoicing tab on card. The Cost fields must have updated, but not the prices.

7. Now run Adjust item-cost prices with adjustment factor 1.5 and check the values. The Unit price over the card must have been updated with 50%.

You can see that the batch job is used to change the prices (Sales prices) of items. After running this batch job, every time when you make a Sales order, the updated Price will be copied to Sales Order field “Unit price Excluding VAT”.
BatchJob-6

Above listed all fields can be adjusted accordingly, specifying Adjustment Factor and Rounding Method.

Similarly it works for SKU also.

Give it a try to understand it more precisely. Follow above steps defined above.

Development Tips

UI Elements Removal

Depending on the setting in the UI Elements Removal field in the Microsoft Dynamics NAV Server Administration tool, only UI elements on objects in the license or on objects that the user has permissions for will appear in the user interface.

For UI elements without a direct relation, you can use the AccessByPermission property to set a value for a table field or UI element that determines the permission mask for an object that a user must have to see and access the related page fields or UI element in the client

To make full use of the LicenseFileAndUserPermissions option in the UI Elements Removal field, it is recommended that you assign the special FOUNDATION permission set to the user along with the relevant application permission sets that define which application objects the user will access. In addition, you must make sure that the user’s application permission sets grant all the functionality access that is not granted by the FOUNDATION permission set alone

A couple of the application permission sets that are provided by Microsoft Dynamics NAV are adapted to support the FOUNDATION permission set for demonstration purposes. To experience how UI elements are removed for a user performing the task to create and edit a new customer, you can create a sample user interface based on the provided permission sets.

For more details see my earlier post AccessByPermission Property – in Navision 2015

Development Tips

Database Schema Synchronization

Microsoft Dynamics NAV 2015 introduces several improvements to the table schema synchronization process that improve performance and make it more explicit and controllable. The improvements give you with the flexibility to decide when and how the table changes are synchronized with corresponding tables in the SQL Server.

In Microsoft Dynamics NAV 2015, changes to the database schema are no longer synchronized automatically to the database when a client connects to a Microsoft Dynamics NAV Server instance. Instead, you specify when to synchronize schema changes in the development environment or the Microsoft Dynamics NAV 2015 Administration Shell.

For example, when you change a table object and compile the table, you can choose to synchronize the change to the database immediately or later. In a production environment, you apply changes to the database schema by running the Sync-NAVTenant Windows PowerShell cmdlet with the Mode parameter set to the relevant synchronization mode.

The schema synchronization design provides the following features and benefits:

  • On-demand schema synchronization and monitoring As a developer or system administrator, from the development environment or Microsoft Dynamics NAV 2015 Administration Shell, you control when to perform the schema synchronization and how to synchronize table changes.This enables you to plan and schedule the schema synchronization on a case-by-case basis. Additionally, you can monitor the progress and state of the business (tenant) database at any time.
  • Non-blocking and increased productivity Schema synchronization has become more granular. You perform schema synchronization for a single table or for all tables at the same time. When one table is being synchronized, you are no longer blocked from making changes to other tables.
  • Capability to provide additional instructions in upgrade codeunits By using upgrade codeunits, you can provide instruction for the schema synchronization to perform additional tasks, such as automatically moving or copying data into upgrade tables, validating the table changes before applying them, or forcefully applying them when it is required.

Please check my earlier post on this topic for more detailed information.

Schema Synchronization in Microsoft Dynamics Navision 2015

Data Upgrade Codeunit in Navision 2015 Part-1

Data Upgrade Codeunit in Navision 2015 Part-2

Development Tips

Data Upgrade – in Navision 2015

Microsoft Dynamics NAV 2015 introduces a new way of running the data upgrade logic that migrates data from the old table structure of an earlier Microsoft Dynamics NAV version to the new table structure of the current version.

The data upgrade process is now prepared and run with the help of new type of codeunit called the upgrade codeunit. The data upgrade process has been enhanced significantly to optimize the performance and provide developers with a superior tool for testing, automating, tracking progress and troubleshooting the data upgrade code. The new data upgrade approach has the following benefits and features:

  • Simplifies the upgrade environment because all steps are performed by the latest version of the Microsoft Dynamics NAV.
  • Increases the data upgrade performance because it is possible to run upgrade functions of upgrade codeunits in parallel (at the same time) and across companies.
  • Reduces the amount of code that is required to handle the data upgrade because several operations are now executed automatically by Microsoft Dynamics NAV Server.
  • Minimizes the number of manual actions that must be performed during the data upgrade, which makes the data upgrade process less error-prone.
  • Uses familiar upgrade toolkit design concepts, such as upgrade tables and upgrade functions.
  • Includes end-to-end sample Windows PowerShell scripts that perform a complete data upgrade.

Please check my earlier post on this topic for more detailed information.

Schema Synchronization in Microsoft Dynamics Navision 2015

Data Upgrade Codeunit in Navision 2015 Part-1

Data Upgrade Codeunit in Navision 2015 Part-2

Development Tips

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
Development Tips

Functions Not Supported by Microsoft Dynamics NAV Web Client

Below is the lists the C/AL functions and data types that are not supported or partially supported by Microsoft Dynamics NAV Web client.

Unsupported Functions

Functions that are not supported by the Microsoft Dynamics NAV Web client. If you use a function that is not supported, an error occurs at runtime.

  • CREATE Function (Automation)
  • ISCLEAR Function (Automation)
  • ACTIVATE Function (Debugger)
  • UPDATE Function (Dialog)

Partially Supported Functions

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

  • DOWNLOAD Function (File)
  • DOWNLOADFROMSTREAM Function (File)
  • HYPERLINK Function
  • PREVIEW Function (Report)
  • PRINTONLYIFDETAIL Function (Report)
  • REPORT.RUN Function
  • REPORT.RUNMODAL Function
  • UPLOAD Function (File)
  • UPLOADINTOSTREAM Function (File)
Development Tips

Not supported in Microsoft Dynamics NAV 2015

The following table provides an overview of the removed C/AL data types, functions, properties, and triggers in Microsoft Dynamics NAV 2015 since the previous version of Microsoft Dynamics NAV.

Data type, function, property, or trigger Not supported in Microsoft Dynamics NAV 2015  
BEEP Function Not supported on Microsoft Dynamics NAV Server.
Binary Data Type The Binary data type, used in earlier versions of Microsoft Dynamics NAV to store fixed lengths of binary data in a record, is not supported in Microsoft Dynamics NAV 2015. If you previously used the BINARY data type, consider using the BLOB Data Type instead.
BottomMargin Property Not supported in Microsoft Dynamics NAV 2015 reports.
COMMANDLINE Function Not supported in Microsoft Dynamics NAV 2015.
COUNTAPPROX Function Not supported in Microsoft Dynamics NAV 2015.
CREATETOTALS Function Redundant in Microsoft Dynamics NAV 2015 reports. We recommend that you use the SUM function in Visual Studio instead.
Dataports Not supported in Microsoft Dynamics NAV 2015. Use XMLports instead.
ENVIRON Function Not supported in Microsoft Dynamics NAV 2015.
EXPORT Function (BLOB) Not supported in Microsoft Dynamics NAV 2015.
EXPORTOBJECTS Function Not supported in Microsoft Dynamics NAV 2015. Use the finsql.exe executable with the ExportObjects command instead.
Forms Not supported in Microsoft Dynamics NAV 2015.
IMPORT Function (BLOB) Not supported in Microsoft Dynamics NAV 2015.
IMPORTOBJECTS Function Not supported in Microsoft Dynamics NAV 2015. Use the finsql.exe executable with the ImportObjects command instead.
ISSERVICETIER Function Obsolete in Microsoft Dynamics NAV 2015, but still supported. This function always returns true.
KeyGroups Property Not supported in Microsoft Dynamics NAV 2015.

Optionally, you can build indexes in SQL Server management tools.

LANGUAGE function Not supported in Microsoft Dynamics NAV 2015.
NEWPAGE Function Not supported in Microsoft Dynamics NAV 2015 reports.
NEWPAGEPERRECORD Function Not supported in Microsoft Dynamics NAV 2015 reports.
OBJECTID Function Not supported in Microsoft Dynamics NAV 2015 reports.
OnCreateHyperlink Trigger Not supported in Microsoft Dynamics NAV 2015 reports.
OnHyperlink Trigger Not supported in Microsoft Dynamics NAV 2015 reports.
OnPreSection Trigger Not supported in Microsoft Dynamics NAV 2015 reports.
OnPostSection Trigger Not supported in Microsoft Dynamics NAV 2015 reports.
OSVERSION Function Not supported in Microsoft Dynamics NAV 2015.
PAGENO Function Not supported in Microsoft Dynamics NAV 2015 reports.
PAPERSOURCE Function Not supported in Microsoft Dynamics NAV 2015 reports.
PaperSourceOtherPages Property Not supported on Microsoft Dynamics NAV 2015 reports.
RECORDLEVELLOCKING Function (Record and RecordRef) Not used in Microsoft Dynamics NAV 2015. The function is still available and compiles but always returns true.
READCONSISTENCY Function (Record and RecordRef) Not used in Microsoft Dynamics NAV 2015. The function is still available and compiles but because Microsoft Dynamics NAV 2015 uses SQL Server’s locking mechanisms and does not use snapshots like earlier versions of Microsoft Dynamics NAV, the return value is always false.
RequestOptionsForm system variable Not supported in Microsoft Dynamics NAV 2015.
SAVEASHTML Function Not supported in Microsoft Dynamics NAV 2015 reports.
SAVEASXML Not supported in Microsoft Dynamics NAV 2015 reports.
SETPERMISSIONFILTER Function (Record) Not supported in Microsoft Dynamics NAV 2015. Instead, you change the SecurityFiltering Property from Validated to Filtered.
SETPERMISSIONFILTER Function (RecordRef) Not supported in Microsoft Dynamics NAV 2015. Instead, you change the SecurityFiltering Property from Validated to Filtered.
SaveTableView property Not supported in Microsoft Dynamics NAV 2015.
SHELL Function Not supported in Microsoft Dynamics NAV 2015.
SHOWOUTPUT Function Not supported in Microsoft Dynamics NAV 2015 reports.
SYNCHRONIZEALLLOGINS Function Not supported in Microsoft Dynamics NAV 2015.
SYNCHRONIZESINGLELOGIN Function Not supported in Microsoft Dynamics NAV 2015
TOTALSCAUSEDBY Function Not supported in Microsoft Dynamics NAV 2015 reports.
URL Function Not supported on Microsoft Dynamics NAV 2015 reports.
VARIABLEACTIVE Function Not supported in Microsoft Dynamics NAV 2015.
VISIBLE Function Not supported in Microsoft Dynamics NAV 2015.
YIELD Function Not supported on Microsoft Dynamics NAV Server.
Comment or Uncomment Selection, Development Tips

Development Environment Enhancements – in Navision 2015

Auto-generating of C/AL variable and parameter names for complex data types

In the C/AL Globals and C/AL Locals windows, when you add a variable or parameter that has the data type Codeunit, Page, Testpage, Report, Query, or XMLport, the Name field will be automatically generated just by setting the DataType and SubType fields. The generated name is based on the name that is assigned to the associated Microsoft Dynamics NAV object. You can change the generated name as you want.
DevelopmentEnvironmentEnhancement-1

Commenting and uncommenting multiple lines of C/AL Code

The development environment includes the Comment Selection and Uncomment Selection options, which enable you to comment and uncomment multiple lines of C/AL code with the click of a button.

For more information, see my earlier post Commenting and uncommenting multiple lines of C/AL Code

Non-default property values are bold

Microsoft Dynamics NAV objects have many properties that you can view and set from the Properties window in the development environment. Property values that are not the default value of the property appear as bold in the Properties window.
DevelopmentEnvironmentEnhancement-2

C/AL functions are local by default

Unlike in earlier Microsoft Dynamics NAV versions, now when you create a function in the C/AL code of a Microsoft Dynamics NAV object, such as a codeunit or page, the function is set as a local function by default. By default, the Local property of new functions is now set to Yes instead of to No. Being local means that the function is not accessible outside the object in which is it defined.

Development Tips, FixedLayout Control, Scope Property, Show Mandatory Property, UpdatePropagation 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