web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

How to create KPI Business chart using Chart Control Add-in in NAV

CDsilva Profile Picture CDsilva 4,188

Introduction:

Business Chart Control Add-in

In Dynamics NAV, you can graphically represent data in charts using Business Chart control add-in. The Business Chart control add-in is provided by the Microsoft.Dynamics.Nav.Client.BusinessChart.dll assembly.

The Business Chart control add-in assembly includes an API that you can use to call methods and properties from C/AL code to build your chart

Use of Business Chart Buffer

Table 485 Business Chart Buffer is a default table which temporarily holds the data for building a chart, such as the chart type, measures, and labels.The purpose of the Business Chart Buffer table is to separate the chart data from the page.

Problem Statement:

Create a Business Chart for Posted Sales Invoice which displays data graphically for the Period Length : Day, Week, Month, Quarter, Year and Location code

KPI1

Objects Used : Table -1 , Pages -2, Codeunit -1

Pre-requisites:

Microsoft Dynamics NAV 2018

Steps:

  1. Create a table.

KPI2

2. Create a page for the business chart or KPI to display.

kpi3

3. In the properties of Business Chart add the Business Chart Control Add-in

kp4

4. Set the properties of the page as below

kpi5

5. Set the page actions to the page

kpi6

6. Code behind the action button are as follows. Update Chart is a function, the code will be explained later in the blog

kpi7

7. Add the below function in the page on below triggers.

kpi8

8. The below function SetActionsEnabled freezes the option in Period Length based on the current Period Length selected.

kpi9

9. Update Chart function calls 4 functions, first one updates the data based on the Period Length, second one updates the charts , third updates the status and fourth updates the status text.

KPIPostedSalesInvoiceMgt is a codeunit.

kpi10

10. Now we add code to the control add-in to generate data on open page. on drill down a function is called from the codeunit KPIPostedSalesInvoiceMgt to open the page on clicking the chart. The default Period length is set to Month.

kpi11

11. Create a codeunit and add the code under onOpenPage as follows. This code will populate the Business Chart Buffer table as Period Length as Month whenever page opens.

kpi12

12. Create a function Update Data. This will update the data in the chart every time we  select the Period Length or refresh the page. Here, Business chart buffer table is initialized to initialize the dot net variables. Set the X-axis and Y axis co-ordinates. Here chart type is selected as Stacked Columns.

kpi14

13. Below is the code for day. Here from Posted Sales Invoice Line fetches the first and last posting date.

kpi15

 

14. Loop through the Date Period and fetch the sum of the amount based on the Location code i.e in this case responsibility center(C1, W1, K1) and Posting dates

kpi18

kpi19.PNG

15. Now we code for drill down i.e if we click on the stack column of the chart it should open the Posted Sales Invoice page with the filters of Period Length and Responsibility Center. we use the date array here to get the posting date of the selected column of the chart.

kpi20

16. Finally, code for Status Text to update when on change of Period Length and refresh of page.

kpi21

Final Result: Add it to the Rolecentre.

kpi13

kpi22

To do


This was originally posted here.

Comments

*This post is locked for comments