Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Panel
nameidblue0

Dashboard components offer a visual representation of data to the user. They consist of an SQL statement, which if needed,

They can be dynamically altered by adding certain filters and criteria. implemented by a Java method that returns the data and a metadata XML file.

What does this section cover?

Table of Contents

...

There are two types of dashboard components, chart and summary.

Chart Dashboard Components

 

To create a new Chart Dashboard Component, you need to create:

  1. An XML file that will define the method that will be called to retrieve the results and the various settings of the dashboard component's data source, type, and various settings.
  2. A Java method that will retrieve the dashboard results.
  3. A summary page that the dashboard component will link to.
  4. A data entry page (definition and layout XML pages) that will give the user the ability to adjust the dashboard settings to apply an additional filtering. (optional)

 

Dashboard Component XML file

 

All dashboard component XML files must be placed under ../pages/dashboards/<module_name> directory.

In the following example completedActinitiesPerTypeAndMonth.xml is created under  ../pages/dashboards/activities

 

Code Block
languagexml
titlecompletedActivitiesPerTypeAndMonth.xml
collapsetrue
<?xml version="1.0" encoding="UTF-8"?><dashboardcomponent xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../xsd/dashboards.xsd">
	<name>key_completed_activities_per_type_and_month</name>
	<description>key_completed_activities_per_type_and_month_stacked_bar_chart</description>
	<ejb>CRMUIActivityDashboard</ejb>
	<method>loadCompletedActivitiesPerTypeAndMonth</method>
	<type>stack</type>
	<orientation>vertical</orientation>
	<primaryfield>ACTIVITIES.ACTIVITYID</primaryfield>
	<primaryfieldlabel>key_number_of_activities</primaryfieldlabel>
	<groupbyfield>ACTIVITIES.ACTTYPEID,ACTUALCLOSINGDATE_FILTER</groupbyfield>
	<groupbyfieldlabel>key_month,_type</groupbyfieldlabel>
	<valuelabels>ejb/CRMUIActivityType.getTypeOptions</valuelabels>
	<summarypage>activities/activitiesPerType</summarypage>
	<setting>
		<page>dashboards/activitiesPerTypeSettings</page>
		<classname>ejb/CRMUIActivityDashboard</classname>
		<method>loadActivitiesPerTypeSettingsForm</method>
	</setting>
</dashboardcomponent>

 

Java Method to Retrieve Results

 

Code Block
languagejava
titleloadNewActivitiesPerTypeAndMonth
collapsetrue
public DashboardComponentData loadNewActivitiesPerTypeAndMonth(
			String dashboardID, 
			String dashboardComponentID, 
			String filterConditions,
			ArrayList<Object> parameters) throws Exception {
		
		CRMDODashboard dashboard = (CRMDODashboard)dashboardBean.load(dashboardID);
		CRMDODashboardComponent dashboardComponent = (CRMDODashboardComponent)dashboardComponentBean.load(dashboard, dashboardComponentID);
		String dashboardComponentSettings = "";
		
		Set<CRMDOActivityType> activityTypes = activityDashboardXMLUtilBean.loadActivityTypesPerTypeFromXML(dashboardComponent);
		
		if (activityTypes!=null && activityTypes.size()>0)
		{
			dashboardComponentSettings += "\n AND ACTIVITYTYPES.ACTTYPEID IN ( ";
			
			Iterator<CRMDOActivityType> iter = activityTypes.iterator();
			
			while (iter.hasNext())
			{
				CRMDOActivityType activityType = iter.next();
				
				dashboardComponentSettings += "\n '" + activityType.getId() + "',";
			}
			
			dashboardComponentSettings = dashboardComponentSettings.substring(0, dashboardComponentSettings.length()-1);
			
			dashboardComponentSettings += "\n )";
		}
		
		String sql = 
				"\n SELECT * FROM ( " +
				"\n 	SELECT	ACTIVITYTYPES.ACTTYPEID, " + 
				"\n				CASE " + 
				"\n				" + DateUtil.getMonthSQL(getCRMSession().getDbtype(), "ACTIVITIES.ACTIVITYSTARTDATE") +
		        "\n 					WHEN '1' THEN 'JAN' " + 
		        "\n 					WHEN '2' THEN 'FEB' " + 
		        "\n 					WHEN '3' THEN 'MAR' " +
		        "\n 					WHEN '4' THEN 'APR' " + 
		        "\n						WHEN '5' THEN 'MAY' " +
		        "\n 					WHEN '6' THEN 'JUN' " +
		        "\n 					WHEN '7' THEN 'JUL' " +
		        "\n 					WHEN '8' THEN 'AUG' " +
		        "\n						WHEN '9' THEN 'SEP' " +
		        "\n 					WHEN '10' THEN 'OCT' " +
		        "\n						WHEN '11' THEN 'NOV' " +
		        "\n 					WHEN '12' THEN 'DEC' " +
                "\n 			END AS MONTH, " +
				"\n				COUNT(ACTIVITIES.ACTIVITYID) AS TOTAL " +
				"\n 	FROM ACTIVITIES " +
				"\n 	INNER JOIN ACTIVITYTYPES ON ACTIVITYTYPES.ACTTYPEID = ACTIVITIES.ACTTYPEID " +
				"\n 	WHERE ACTIVITIES.ACTIVITYDELETED = 0 " +
				"\n 	AND ACTIVITYTYPES.ACTTYPEDELETED = 0 " +
				"\n 	" + dashboardComponentSettings +
				"\n 	" + filterConditions +
				"\n 	AND " + DateUtil.getSQLFirstDayOfMonthDate(getCRMSession().getDbtype(), "ACTIVITIES.ACTIVITYSTARTDATE")+" >= " + DateUtil.addMonthsSQLDate(getCRMSession().getDbtype(), DateUtil.getSelectSQLDate(getCRMSession().getDbtype(), DateUtil.getFirstDateOfMonth(getCurrentDate())), -12) + " " +
				"\n 	GROUP BY 	ACTIVITYTYPES.ACTTYPEID, " + 
				"\n 		 		CASE " + 
				"\n					" + DateUtil.getMonthSQL(getCRMSession().getDbtype(), "ACTIVITIES.ACTIVITYSTARTDATE") +
				"\n 					WHEN '1' THEN 'JAN' " + 
				"\n 					WHEN '2' THEN 'FEB' " + 
				"\n 					WHEN '3' THEN 'MAR' " +
				"\n 					WHEN '4' THEN 'APR' " + 
				"\n						WHEN '5' THEN 'MAY' " +
				"\n 					WHEN '6' THEN 'JUN' " +
				"\n 					WHEN '7' THEN 'JUL' " +
				"\n 					WHEN '8' THEN 'AUG' " +
				"\n						WHEN '9' THEN 'SEP' " +
				"\n 					WHEN '10' THEN 'OCT' " +
				"\n						WHEN '11' THEN 'NOV' " +
				"\n 					WHEN '12' THEN 'DEC' " +
				"\n 				END " +
				"\n ) TEMP " +
				"\n ORDER BY ( " + 
				getOrderByWithCurrentMonthPriority() + 
		 		"\n ), ACTTYPEID "; 
		
		ResultSetUtil data =  SQLUtil.executeUsingPreparedStatement(sql, getOrganisationID(), parameters, getCRMSession().getDbtype());
	
		DashboardComponentData componentData = new DashboardComponentData(data);
		
		return componentData;
	}

 

Defining Dashboard Components in Metadata

 

In order for the report Also, in order for the dashboard to be available to the user, it must be defined in metadata file modules.xml, which is located under ../metadata directory.

Expand
titleCompleted Activities Per Type And Month

Image Added

Summary Dashboard Components

To create a new Summary Dashboard Component, you need to create:

  1. An XML file that will define the component's data source, type, and various settings.
  2. The embedded summary page that will retrieve and display the dashboard results.

Also, in order for the dashboard to be available to the user, it must be defined be defined in metadata file file modules.xml, which is located under under ../metadata directory directory.

 <modules> <module> <moduleid>ACCOUNTS_RECEIVABLE</moduleid> <applicationid>FINANCE</applicationid> ... <features> <feature> ... <reports> <report> <id>ACCOUNTS_RECEIVABLE_BALANCE_REPORT</id> <name>key_accounts_receivable_balance</name> <description>key_view_the_accounts_receivable_balance</description> <reportfilename>AccountsReceivable/Accounts_Receivable_Balance.xml</reportfilename> </report> ... </reports> </feature> ... </features> </module> </modules>
Code Blockexpand
languagexml
titlemodules.xml
titleNon completed activities of logged in user

Image Added


For more information on creating dashboard components, go to Create Dashboard ComponentsFor a full list of metadata dashboard attributes, go to Dashboards Metadata.