Panel | ||
---|---|---|
| ||
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?
|
There are two types of dashboard components, the chart and the summary components.
Chart Dashboard Component
Creating Chart Dashboard Components
To create a new Chart Dashboard Component, you need to create:
...
Expand | ||
---|---|---|
| ||
Dashboard Component XML file
All dashboard component XML files must be placed under ../pages/dashboards/<module_name> directory.
...
For a full list of dashboard component XML file attributes, go to Dashboard Components Documentation.
Java Method to Retrieve Results
The method should:
- Construct the SQL script that will be used to retrieve the results.
- 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.
- Convert com.crm.framework.util.ResultSetUtil to com.crm.process.dashboards.DashboardComponentData using DashboardComponentData class constructor.
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
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; } |
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.
...
Expand | ||
---|---|---|
| ||
|
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 Pages.
Expand | ||
---|---|---|
| ||
Summary Dashboard Components
Creating Chart Dashboard Components
To create a new Summary Dashboard Component, you need to create:
- An XML file that will define the component's data source, type, and various settings.
- The embedded summary page that will retrieve and display the dashboard results.
Expand | ||
---|---|---|
| ||
Dashboard Component XML file
All dashboard component XML files must be placed under ../pages/dashboards/<module_name> directory.
In the following example nonCompletedActivitiesSummary.xml is created under ../pages/dashboards/activities
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<?xml version="1.0" encoding="UTF-8"?><dashboardcomponent xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../xsd/dashboards.xsd">
<name>key_non_completed_activities_of_logged_in_user</name>
<description>key_non_completed_activities_of_logged_in_user</description>
<type>summary</type>
<summarypage>activities/dashboardActivities</summarypage>
</dashboardcomponent> |
For a full list of dashboard component XML file attributes, go to Dashboard Components Documentation.
Dashboard Component Embedded Summary Page
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<?xml version="1.0" encoding="UTF-8"?><summary xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../xsd/summary.xsd">
<title>key_activities</title>
<sql>FROM ACTIVITIES
LEFT JOIN ACTIVITYTYPES ON ACTIVITYTYPES.ACTTYPEID = ACTIVITIES.ACTTYPEID
LEFT JOIN ACTIVITYSTATUSES ON ACTIVITIES.ACTSTATUSID = ACTIVITYSTATUSES.ACTSTATUSID
WHERE ACTIVITIES.ACTIVITYDELETED = 0
AND ACTIVITIES.LIFECYCLESTATE <> 'COMPLETED'
<!-- for logged in user -->
</sql>
<rowsperpage>5</rowsperpage>
<primaryfield>ACTIVITIES.ACTIVITYID</primaryfield>
<mainlinkfield>ACTIVITIES.ACTIVITYNUMBER</mainlinkfield>
<module>ACTIVITIES</module>
<entityfilter>ACTIVITIES</entityfilter>
<fieldlist>
<!-- external filters -->
<!-- basic search -->
<field>
<fieldname>ACTTYPE_FILTER</fieldname>
<fieldfunction>ACTIVITIES.ACTTYPEID</fieldfunction>
<caption>key_type</caption>
<filter>true</filter>
<filterlookupname>dataset;activities.loadtypes;acttypeid;acttypename</filterlookupname>
</field>
<!-- advanced search -->
<!-- fields -->
<field>
<fieldname>ACTIVITIES.ACTIVITYNUMBER</fieldname>
<caption>key_number</caption>
<summary>true</summary>
<link>page.do?xml=activities/activity&act=itm&jndi=ejb/CRMUIActivity&fc=loadForm&pv0=((ACTIVITIES.ACTIVITYID))&pvc=1</link>
</field>
<field>
<fieldname>ACTIVITIES.ACTTYPEID</fieldname>
<caption>key_type</caption>
<summary>true</summary>
<fixedlookup>ejb/CRMUIActivityType.getTypeOptions:key_all</fixedlookup>
</field>
<field>
<fieldname>ACTIVITIES.ACTIVITYDESC</fieldname>
<caption>key_description</caption>
<summary>true</summary>
</field>
<field>
<fieldname>ACTIVITYSTATUSES.ACTSTATUSNAME</fieldname>
<caption>key_status</caption>
<summary>true</summary>
</field>
<field>
<fieldname>ACTIVITYEXPECTEDCLOSINGDATE</fieldname>
<fieldfunction>ACTIVITIES.ACTIVITYEXPECTEDCLOSINGDATE</fieldfunction>
<caption>key_expected_completion_date</caption>
<summary>true</summary>
</field>
<!-- drilldowns -->
</fieldlist>
</summary> |
Defining Dashboard Components in Metadata
...