Microsoft Dynamics NAV

Microsoft Dynamics NAV 2013 – Business Chart explained


In this blog, I’m going to talk about Business Charts in detail and how you can create them from scratch.

Building Business Charts is one of the ways you can take advantage of the powerful charting capabilities in Dynamics NAV.

Please refer to my previous blog post (Building Charts in Microsoft Dynamics NAV 2013 R2) to know about different ways of building charts in NAV.

WHAT ARE BUSINESS CHARTS?

Business charts are based on Business Chart control add-in which is provided by the Microsoft.Dynamics.Nav.Client.BusinessChart.dll assembly. More details about Displaying the Charts using Chart control add-in here

As compared to other chart types, Business charts provide advanced functionalities such as:

  • Displaying complex data that is calculated on a page.
  • Allowing end users to filter data and drill down to the details from the chart
  • Allowing dynamic filtering of data
  • Being supported on Dynamics NAV Web client.

EXPLORE EXISTING BUSINESS CHARTS:

Out of the box, in the Cronus demo database, there are a few business charts available such as Trailing sales orders, Cash flow chart, Finance performance, Sales performance, Inventory performance etc.. These charts can be used on Role centers or along with pages.

For ex, In the Cronus demo database, when we login with President’s profile, we can view multiple business charts as shown below:

Business charts on President RoleCenter
Business charts on President RoleCenter

Tips:

  • If you’re not able to see these charts on the President role center, you can add them by using Customize this page option.
  • Once added, if there is nothing shown on these graphs, change the filters using Select Chart or Show buttons on these charts.
  • When the chart is displayed, click on the chart to experience the drill down functionality.
  • Experience interactive features using Period Length, group by, Start Date and other options on these charts.
  • Each of these charts are nothing but a CardPart pages at the backend.

 

BUILDING BUSINESS CHARTS FROM SCRATCH

At the end of this blog, you will know how to build a simple Business chart which can be used as a factbox in the Item list page showing location wise Inventory. This chart updates automatically when you move to any particular line on the item list page.

Location wise Inventory
Location wise Inventory

 

Location wise Inventory Business Chart:

We need to mainly use Business Chart Buffer table (485) to build the business charts. This table holds chart related values and also has multiple functions pre-defined which can be used to build our chart on a page object.

Following objects are required to build Location wise Inventory Business Chart:

1. A Query to calculate Location wise remaining quantity for all the items

2. A Codeunit to use the above query result and prepare Business Chart Buffer table.

3. A Page to display the chart.

-> Design

1. Design a new Query object which shows Location wise remaining quantity for all the items. We will be using the query result as chart data.

a. Open Dynamics NAV development environment and click on Query and next click on New to design a new query

b. Specify the query DataItem and columns as shown below:

Query designer -  Location wise remaining quantity for all the items
Query designer – Location wise remaining quantity for all the items’

c. Save the query. (ex: ID-65000 and Name-Item qty. location wise)

d. Run the query (65000) to see location wise total quantity of items.

Query result
Query result

 

2. Design a new CodeUnit to populate the Business chart buffer table with the above query result.

a. In the Dynamics NAV development environment, click on Codeunit and next click on New to design a new Codeunit.

b. In the codeunit designer, click on View–> Globals–> Functions tab to create a new function in the Codeunit. Enter the function name as GenerateDataInventorybyLoc and click on Locals button to enter parameters and variables for the function as shown in the below image:

Function name, parameters and variables definition
Function name, parameters and variables definition

 

c. Now in the Codeunit designer you see an new function trigger called GenerateDataInventorybyLoc. Enter the code as shown in the below image. The in-line comments within the Codeunit explains more about each line of code:

Codeunit used to generate the business chart
Codeunit used to generate the business chart

d. Save the Codunit (ex: ID-65000 and Name-Items qty by loc. chart mgt.)

 

3. Design a new Page object to display the Business Chart.

a. In the Dynamics NAV development environment, click on Page and next click on New to design a new page object.

b. In the Page design wizard, Specify Table as Item and Page type as CardPart as shown below and click on Ok. Click on Finish to close the Page design wizard.

Page design wizard
Page design wizard

c. Insert a field in the page with name Chart and click on field properties button. Specify the ControlAddIn property for the Chart field as highlighted below. (You need to choose Microsoft.Dynamics.Nav.Client.BusinessChart control add-in)

Page designer and Field properties
Page designer and Field properties

 

d. In the page designer click on C/AL Code (F9) button to open the triggers. We will see additional triggers being added below for this control add-in field:

Control add-in triggers
Control add-in triggers

 

e. we’ll define a new function within this page. click on View–> Globals–> Functions tab to create a new function in the Codeunit. Enter the function name as UpdateChart and click on Locals button to enter variables for the function as shown in the below image:

Function within the page to update chart
Function within the page to update chart

 

f. Click on C/AL Code (F9) again to open triggers. Enter the Code as shown in the below image:

UpdateChart function call and defination
UpdateChart function call and definition

g. Save the page. (ex: ID-65000 and Name-Items Qty by location chart)

 

4. The Business chart is now ready to be displayed! Add it to the Item list page as a Page part

a. In the Dynamics NAV development environment, click on Page and find the Item List page. Click on Design and go to the last line of the page designer. Enter a new line as shown below:

Add the Business chart to Item List Page
Add the Business chart to Item List Page

b. click on Properties to open the Page Part properties and specify PagePartID and SubPageLink as shown below:

Page Part properties
Page Part properties

c. Save the Item List page.

5. Open/refresh your Item list page on the NAV Windows/Web client to see a factbox showing Location wise Inventory Chart. Select different items to see the graph change respectively.

The below Image shows the Item List page in Windows client:

Location wise inventory in Item List page
Location wise inventory in Item List page

 

IN MY NEXT BLOG:

I will explain how to drilldown to details by clicking on parts of a business chart.

Thanks for reading my blog. Feel free to leave a comment.

 

 

Advertisements

19 thoughts on “Microsoft Dynamics NAV 2013 – Business Chart explained”

    1. Hi Asharaf, Do you want to export Business charts to another NAV 2013 database?? If yes, the answer is yes. You can export the related objects from one database and import these objects into another database.

      Like

      1. I need to export standard Cronus charts which is available in table 2000000078. It was not working When I was tried through the Rapid start and export XML….

        Like

  1. Hi Asharaf, I just tried below steps in my test database and it worked:

    In Cronus DB:
    1. Create an XMLPort (55000) using the table 2000000078 and fields: ID and Name (Do not include BLOB)
    2. Run XMLPort (55000) and export all the data from table 2000000078 into XMLfile (charts1.xml)
    3. In windows client open Generic charts–> Select all charts–> Under actions tab click on Export Chart–> Save XMLfile (charts2.xml)

    In New DB:
    1. Import XMLPort (55000) object which was created in Cronus DB.
    2. Run XMLPort (55000) and import the chart1.xml file. This fills up the Chart table (2000000078)
    3. In windows client open Generic charts–>Under actions tab click on Import Chart and import chart2.xml.

    Let me know if you face any issues. Thanks.

    Like

    1. !!!! thanks for your reply. Its work fine except below step. Only first chart exported even though I have selected all.
      3. In windows client open Generic charts–> Select all charts–> Under actions tab click on Export Chart–> Save XMLfile (charts2.xml)

      Its importing the first line only When I am importing charts2.xml.

      once again thanks for knowledge sharing. 🙂

      Like

  2. Hi! I tried creating Business charts but I’m getting an error while opening Item list page. It shows Dotnet variable has not been instantiated.Attempting to call
    Microsoft.Dynamics.Nav.Client.BusinessChart.BusinessChartData.Datatable in Table Business Chart Buffer:Update
    Also While creating Page (3 step f) I am not getting LOCAL UpdateChart(). I got UpdateChart() alone.
    I even tried to import the fob file which you created in the next blog of Charts but its said version is different but I am using Nav 2013 only.. Kindly help me out to resolve it.

    Like

    1. Hi Saravana,
      I have tried this on NAV 2013 R2 and the objects can be imported in NAV 2013 R2 database.
      It does not matter if LOCAL is not shown along with your function. That should not be the problem.
      Not sure why there is an error! Check if everything is in place, compile the objects again and run. Let me know if you still have issues.

      Like

    2. @Saravan
      I got the same error, defining the Parameter BusChartBuf in function GenerateDataInventorybyLoc in the cu65000 as VAR helped.

      Like

    1. I think that it’s not possible directly but you can add some empty measures.
      You are still restricted by the default colors but at least you can choose.

      Like

  3. Hi it’s very usefull but I have an error while I try to save page (ex: ID-65000 and Name-Items Qty by location chart). Error is:
    “When the function is called, the minimum number of parameters should be used. For example:
    MyFunc( .. , .. , .. )
    ROUND(MyVar)
    ROUND(MyVar,0.05)”
    and system stops at UpdateChart line.
    What need I to improve in my objects?

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s