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, can be dynamically altered by adding certain filters and criteria. 

What does this section cover?

Table of Contents

There are two types of dashboard components, chart and summary. For an introduction to dashboard components, go to Dashboard Components.

Chart Dashboard Components

...

, go to Dashboard Components.

Create Dashboard Components

To create a new dashboard component you need to:

  1. Create the dashboard component. You can create either a chart or a summary dashboard component
      1. Create chart dashboard component
        1. Create an XML file that will define the component's data source, type, and various settings.
        2. Create a Java method OR an SQL statement that will retrieve the dashboard results.
        3. Create a summary page that the dashboard component will link to.
        4. Create 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)

      2. Create summary dashboard component
        1. Create an XML file that will define the component's data source, type, and various settings.
        2. Create the embedded summary page that will retrieve and display the dashboard results.
  2. Define the dashboard component in the metadata.

1i. Create Chart Dashboard Components

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

  1. An XML file that will define the component's data source, type, and various settings.
  2. A Java method OR an SQL statement 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)

 


Expand
titleCompleted Activities Per Type And Month

1. Dashboard Component XML file

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

In the following example completedActinitiesPerTypeAndMonth.xml is created under <custom_project>/web/WebContent/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,key_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>

For a full list of dashboard component XML file attributes, go to Dashboard Components Documentation.

2. Java Method to Retrieve Results

The method should:

  1. Construct the SQL script that will be used to retrieve the results.
  2. Use executeUsingPreparedStatement(sqlStatement, dbName, parameters, dbType) method of SQLUtil class, to retrieve the results and put them in a variable of type com.crm.framework.util.ResultSetUtil.
  3. Convert com.crm.framework.util.ResultSetUtil to com.crm.process.dashboards.DashboardComponentData using DashboardComponentData class constructor.

...

Code Block
languagejava
titleloadCompletedActivitiesPerTypeAndMonth
collapsetrue
public DashboardComponentData loadCompletedActivitiesPerTypeAndMonth(
			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.ACTIVITYACTUALCLOSINGDATE") +
		        "\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 ACTIVITIES.LIFECYCLESTATE = '" + ActivityLifeCycleState.COMPLETED.toString() + "' " +
				"\n 	" + dashboardComponentSettings +
				"\n 	" + filterConditions +
				"\n 	AND " + DateUtil.getSQLFirstDayOfMonthDate(getCRMSession().getDbtype(), "ACTIVITIES.ACTIVITYACTUALCLOSINGDATE")+" >= " + 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.ACTIVITYACTUALCLOSINGDATE") +
				"\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);
		
		String summaryFilter = "LIFECYCLESTATE_FILTER~" + ActivityLifeCycleState.COMPLETED.toString();
		
		componentData.addSummaryFilter(summaryFilter);
		
		return componentData;
	}

3. Dashboard Linked Summary Page

The fields defined in <primaryfield> and <groupbyfield> in dashboard component page, and the summary filters defined in the java method should all exist in the dashboard summary page.

...

For more information on creating summary pages, go to Summary PagesDeveloping summary pages (Deprecated).

4. Dashboard Settings Data Entry Page

Creating a dashboard settings data entry page is just like creating any other data entry page. For more information on creating data entry pages, go to Data Entry PagesDeveloping data entry pages (Deprecated).

Expand
titleActivities Per Type Settings

1ii. Creating Summary Dashboard Components

Creating Chart Dashboard Components

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

...

Expand
titleNon completed activities of logged in user

1. Dashboard Component XML file

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

...

For a full list of dashboard component XML file attributes, go to Dashboard Components Documentation.

2. Dashboard Embedded Summary Page

In the following example dashboardNonCompletedActivities.xml is created under <custom_project>/web/WebContent/pages/summary/activities

...

For more information on creating summary pages, go to Summary PagesDeveloping summary pages (Deprecated).

2. Define Dashboard

...

Component in Metadata

In order for the dashboard to be available to the user, it must be defined in metadata file modules.xml, which is located under <custom_project>/web/WebContent/metadata directory

Code Block
languagexml
titlemodules.xml
collapsetrue
 <modules>
    <module>
        <moduleid>ACCOUNTS_RECEIVABLE</moduleid>
        <applicationid>FINANCE</applicationid>
        ...
        <features>
            <feature>
                ...
                <dashboardcomponents>
                    <dashboardcomponent>
						<id>COMPLETED_ACT_PER_TYPE_MONTH</id>
						<name>key_completed_activities_per_type_and_month_stacked_bar_chart</name>
						<description>key_completed_activities_per_type_and_month_stacked_bar_chart</description>
						<filename>activities/completedActivitiesPerTypeAndMonth</filename>
					</dashboardcomponent>
                    ...
                </dashboardcomponents>
            </feature>
            ...
        </features>
    </module>
</modules>

...


Below you can see the available dashboard components when setting up a new dashboard.

Expand
titleSet up new Dashboard

...


For a full list of metadata dashboard attributes, go to Dashboards Metadata.