Thursday 15 December 2016

Microsoft dynamics NAV Report

In simple term, Report is used to display certain information as specified in your filter from a database. Two important tasks are required to create a report
  • Designing the data model or dataset by using Report Dataset Designer
  • Design the Visual Layout: Also divided into 2
    • RDLC - Client Report Definition report Layout: created using Visual Studio Report Designer or SQL Server Report Builder.
    • Word Layout: created using Microsoft.
NB: I will only go into RDLC only

Report Dataset determines the data that is extracted or calculated from the Microsoft Dynamics NAV database tables that can be used in a report. Report Dataset is built from data items --which are tables and columns -- which can be any of these: field, variable, expression or text constant.

How to Create a Report Dataset
  • Open the Object Designer and select Report from the left navigation pane.
  • Click New to open a new Report
  • In the first blank line select the data item, the datasource and a CLS complaint name as the name.
  • In the second line select the column(s) you want for your report. 
    • Click View >> Select Field Menu to choose the fields you want. You can select multiple by holding down CTRL or SHFT key.
  • You can link Tables by indenting data items (table) under another data items (table)
    • Make sure you verify the DataItemLinkReference property is set to the Parent data item.
    • Also use the DataItemLink to connect the Tables - just like in SQL connecting the primary key to the foreign key (by setting the field and reference field)

Design the Visual Layout

The layout is designed in Microsoft Visual Studio Report Designer
It starts by opening Visual Studio Report Designer from the Report Object Designer in NAV Development environment.

  • Report >> Design
  • Click View >> Layout: this opens visual studio.
  • On VS, Click View >> Report Data: pin this to the left navigation pane of the IDE

From the Toolbox, drag a Table to the Designer, Right-Click the header to add Column (as many as required).
It is good practice not to hard-code your table therefore follow these steps to name your header and textbox values

  • Right-Click the header >> select Expression 
  • For the header. Select the parameter and double click the value. Repeat this step for all your headers


  • For the textbox: Select the Fields (second row) and double-click the value. Repeat this step for all your textboxes.



In the Properties window, select the Table properties and set the property DataSetName to DataSet_Result -which is automatically done by visual studio.

The Request Page

Request pages enable end users to specify options and filters for a report. It is created by default when a new report created. In addition, you can create custom options in the Request Page.You design these options  y using the Request Options Page Designer which is accessed from the Report Designer.

There are so any properties and functionalities in Report that I can't cover half of it in this blog, so I'll advice you to visit MSDN for more information

BUT
The headache here is that any visual design has to be done in Visual Studio and  you have to close VS before you can run the report on the RoleTailoredClient. This means any little customization requires you to open VS, make customization and close VS again before running report. 

Thursday 8 December 2016

Could not load file or assembly

I noticed after my upgrade to Microsoft Dynamics NAV 2015 version 8.00.40938  I get an error message on one of the boxes in my RoleCenter View 
"Control Add-in is missing could not load file or assembly Microsoft.Dynamics.Nav.Client.BusinessChart.Model".
I realized I was missing something then I tried this

This resolved my issue
I copied the BusinessChart Folder from my NAV Setup file into two paths on my C-drive
  •  C:\Program Files\Your_Path\Add-in\
  •  C:\Program Files (x86)\Your_Path\Add-in\
With this I was good to go. Happy me!!

Microsoft Dynamics NavClient stopped working


I read a lot of blogs to fix this issue but they all didn't work for me until I stumbled upon this, followed the one-time-step and it worked. This is the link to the step. Click here


How to Check the service running on your port.

I installed Microsoft Dynamics Nav 2015 on my machine and when I run it I get an error saying "Nav can't create a connection to the server". As usual I checked my event viewer to get a detailed message of the error. Then I found out another service -an earlier version of Microsoft Dynamics NAV (2013) was running on the same port as my Nav 2015. How did I know this?
  • Open command line
  • To check Service running on your port
    netstat -noa | find "port number" : It displays the PID
  • tasklist | find "PID"  : It displays the name of service running on your port which you can trace on Task Manger to disable it
Note: The PID is the last number after LISTENING
These simple steps saved my day as I was able to stop the process running on my port in Task Manager.



Tuesday 6 December 2016

Microsoft Dynamics NAV Codeunit

Codeunit is a container for C/AL code that you can use across different application objects. -- just think of it as a class of functions.

Codeunit by default contains two functions: Documentation and OnRun
Documentation: where you write descriptive information about the codeunit
OnRun: It executes any code when you run the codeunit.

By using codeunit, you eliminate the need for duplicate code and make code easier to maintain. You can access the codeunit's function from another codeunit by declaring a datatype of codeunit in a variable and specifying the name of the codeunit in the subtype. Then you can do this 
<CodeunitVariableName>.<FuntionName>. To access a codeunit from other application objects, you must set the Local Property of the function to "No"


Microsoft Dynamics NAV Table

There are 3 types of a table in MS Dynamics NAV namely:

  1. Temporary Table
  2. System Table
  3. Virtual Table
Temporary Table: This is a temporary variable that holds a table. It is used as a buffer for table data.It is similar to a database table but differs in the sense that it is not stored in the database it is only held in memory until the table is closed.

System Table: This table is required for Microsoft dynamics NAV to work properly. Do not make changes to this table because the changes may not be valid for the future upgrade of NAV. System table is stored in the database and is automatically created.

Virtual Table: This table contains system information. You can not change the table data but read the information only. Unlike System Table, it is not stored in the database but computed by Microsoft Dynamics NAV at runtime.

SIFT: SumIndexField Technology.
It allows a user to quickly calculate decimal columns in a table. It is used to optimize the performance of Flowfields. A SumIndexField is always associated with a key. Microsoft Dynamics NAV uses Indexed View to maintain a SIFT key.

FlowField
It is a result of the calculation described in the CalcFormula Property. It is not a physical field that is stored in the database. There are 7 types of flowfield namely:  Sum, Average, Exist, Count, Min, Max, Lookup. A flowfield is always associated with a calculation formula.
How to Create a FlowField
  1. Open Object Designer and select a Table, click Design.
  2. Select a field you want for flowfield calculation.
  3. Click properties, select flowfield in dropdown menu for FieldClass property.
  4. Click the assist button for CalcFormula property to define your calculation for the flowfield

Thursday 10 November 2016

SOLUTION

Solutions exist so that a set of customization can be purchased, shared or otherwise transported from one organization to another. It is a container for a set of components. 

Default Solution
When you customize the CRM system directly, you work with a special solution called the Default Solution. The Default Solution contains all the components in your system. Creating solutions is optional. You can customize your CRM system directly without ever creating a solution. You can only export your Default Solution as an unmanaged solution.

If a new solution is created, it references the components in the default solution and not copies of the components. So a custom or new solution is just a wrapper of the components of the default solution.


Managed Solution
A managed solution are used for distribution of solution. All the components of the solution are removed by uninstalling the solution. To create a managed solution, you choose the managed solution option when you export the solution. If you create a managed solution, you can’t import it back into the same organization you used to create it. You can only import it into a different organization

Unmanaged Solution
These are solutions used during development because they are customizable. When imported into an organization it over-writes the changes or custom development/customization of the latest solution in the organization. 

Versioning Solution
There are four numbers used separated by dots. e.g 1.2.3.4 
Sequentially, they are named (MMBR)

  • Major version number
  • Minor version number
  • Build number
  • Revision number
The first two numbers are updated when a new feature is added to the solution and the last two when a bug is fixed in the solution.

Customizing Solution after Exporting
It is possible to customize Managed solution after exporting the solution because by default Microsoft Dynamics CRM set "Can be Customized" property in the Managed Properties of every solution to true. If you want to restrict access to custom adjustments of the solution you have to set this property to false

Tuesday 1 November 2016

Import Data from Excel into SQL Sever

So again today I faced another challenge as expected. The task for today was to import and merge data from four tables in a database located in a certain/specified server into a single table of an existing database on another server.
Connecting to the server wasn't the hard part, copying the data into an excel sheet and saving it as a CSV format wasn't either. It was importing of the data brought a headache. 
This is why I love Google. I get answers

These are the steps I followed to get the job done
Note: Create a Destination Table
  1. Convert the Excel format to  xlsx  because it's the only format accepted. 
  2. Connect to SQL Management studio, right-click the database , select "task" then "Import Data" 
  3. Select "Microsoft Excel" as the Source  and Choose the "File Location" then Follow the Wizard steps as shown on the screen.
  4. A table is created in the Database and it uses the Excel Title as the Table Name.
  5. Right-click on the Table, "Script Table as" ==>  "CREATE To" to get the CREATE Format of the table for your destination Table where all the data will eventually be. Copy and Run the script in your existing table to generate column names
  6. Right-Click on the Database, select "task" ==> "Generate Scripts" and Follow the Wizard to the Scripting Options page
  7. Select "Advanced" on the "Types of data to script" select any option that suits what you want to do
  8. Click on the file menu to add a file (the Generate script you just saved). once loaded edit the table name to point to the new Table (Destination table) and run the Query.
  9. Run Select (*) FROM Destination Table to confirm it has records.
  10. Repeat steps for all other Tables. 

An excel sheet can't take more than 1,048,576 rows.

Monday 31 October 2016

PLUG-IN

What is a plug-in, Why do we need a plug-in,  When should a plug-in be used?

The What

Plug-ins are handlers that handles event fired or raised by the Microsoft Dynamics CRM platform. It could be an entity e.g. account, lead e.t.c. Plug-ins are event handlers since they are registered to execute in response to a particular event being fired by the platform. You can subscribe, or register, a plug-in to a known set of events to have your code run when the event occurs.

The Why

  • Modify or augment the standard behavior of the platform



The When

  • When you need to enforce business logic in your database that you cannot accomplish reasonably with built in tools like workflows
  • When your business logic must be executed synchronously or asynchronously

Debug Plug-in CRM 2013


Debugging Plug-in goes hand-in-hand with profiling in CRM. It is best to use the plug-in registration tool to debug your plug-in and also analyze the plug-in through profiling. Going through the CRM SDK 2013 and some online researches like Debugging Plug-in will give a better understanding on how to debug a plug-in CRM.