...
- An XML file that will define the method that will be called to retrieve the results and the various settings of the dashboard
- A Java method that will retrieve the dashboard results.
- A summary page that the dashboard component will link to.
A data entry page that will give the user the ability to adjust the dashboard settings. (optional)
Expand | ||
---|---|---|
| ||
Dashboard Component XML file
...
- 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.
- To add any additional summary filters to the summary page linked to the dashboard component, use addSummaryFilter method as shown in the following example.
The method must always return a result of type com.crm.process.dashboards.DashboardComponentData
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
public DashboardComponentData loadNewActivitiesPerTypeAndMonthloadCompletedActivitiesPerTypeAndMonth( 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.ACTIVITYSTARTDATEACTIVITYACTUALCLOSINGDATE") + "\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 ACTIVITYTYPESACTIVITIES.ACTTYPEDELETEDLIFECYCLESTATE = 0'" + ActivityLifeCycleState.COMPLETED.toString() + "' " + "\n " + dashboardComponentSettings + "\n " + filterConditions + "\n AND " + DateUtil.getSQLFirstDayOfMonthDate(getCRMSession().getDbtype(), "ACTIVITIES.ACTIVITYSTARTDATEACTIVITYACTUALCLOSINGDATE")+" >= " + 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.ACTIVITYSTARTDATEACTIVITYACTUALCLOSINGDATE") + "\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; }String summaryFilter = "LIFECYCLESTATE_FILTER~" + ActivityLifeCycleState.COMPLETED.toString(); componentData.addSummaryFilter(summaryFilter); return componentData; } |
Dashboard 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.
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 USERS CREATEDBY ON CREATEDBY.USERID = ACTIVITIES.ACTIVITYCREATEDBYUSERID
LEFT JOIN USERS UPDATEDBY ON UPDATEDBY.USERID = ACTIVITIES.ACTIVITYLASTUPDATEDBYUSERID
LEFT JOIN ACTIVITYTYPES ON ACTIVITYTYPES.ACTTYPEID = ACTIVITIES.ACTTYPEID
...
WHERE ACTIVITIES.ACTIVITYDELETED = 0 AND ACTIVITYTYPES.ACTTYPEDELETED = 0
</sql>
<styleclass>((ACTIVITIES.LIFECYCLESTATE))=='COMPLETED'|disabled</styleclass>
<rowsperpage>20</rowsperpage>
<primaryfield>ACTIVITIES.ACTIVITYID</primaryfield>
<mainlinkfield>ACTIVITIES.ACTIVITYNUMBER</mainlinkfield>
<multiselect>true</multiselect>
<entityfilter>ACTIVITIES</entityfilter>
<module>ACTIVITIES</module>
<fieldlist>
<!-- external filters -->
<field>
<fieldname>ACTIVITIES.ACTIVITYID</fieldname>
<filtertextoption>equal</filtertextoption>
</field>
...
<!-- fields -->
<field>
<fieldname>ACTIVITIES.ACTIVITYNUMBER</fieldname>
<caption>key_number</caption>
<summary>true</summary>
<available>true</available>
<filter>true</filter>
<filteravailable>true</filteravailable>
<link>page.do?xml=activities/activity&act=itm&jndi=ejb/CRMUIActivity&fc=loadForm&pv0=((ACTIVITIES.ACTIVITYID))&pvc=1</link>
</field>
<field>
<fieldname>ACTUALCLOSINGDATE_FILTER</fieldname>
<fieldfunction>ACTIVITIES.ACTIVITYID</fieldfunction>
<caption>key_month</caption>
<filter>false</filter>
<filteravailable>false</filteravailable>
<fieldtype>sql</fieldtype>
<filtercaseinsensitive>false</filtercaseinsensitive>
<filtercondition>
ACTIVITIES.ACTIVITYID IN (
SELECT ACT.ACTIVITYID FROM ACTIVITIES ACT
WHERE (
CASE SQL_MONTH[ ACT.ACTIVITYACTUALCLOSINGDATE ]SQL_MONTH
WHEN '1' THEN 'JAN'
WHEN '2' THEN 'FEB'
WHEN '3' THEN 'MAR'
WHEN '4' THEN 'APR'
WHEN '5' THEN 'MAY'
WHEN '6' THEN 'JUN'
WHEN '7' THEN 'JUL'
WHEN '8' THEN 'AUG'
WHEN '9' THEN 'SEP'
WHEN '10' THEN 'OCT'
WHEN '11' THEN 'NOV'
WHEN '12' THEN 'DEC' END
) ='#1'
AND ACT.ACTIVITYACTUALCLOSINGDATE >= SQL_ADD[M,-13,SQL_GETDATETIME]SQL_ADD
AND ACT.ACTIVITYDELETED = 0
)
</filtercondition>
<filteronexpand>false</filteronexpand>
</field>
<field>
<fieldname>LIFECYCLESTATE_FILTER</fieldname>
<fieldfunction>ACTIVITIES.LIFECYCLESTATE</fieldfunction>
<caption>key_life_cycle_state</caption>
<summary>false</summary>
<filter>true</filter>
<fixedlookup>ejb/CRMUIActivity.getLifeCycleStateOptions:key_all</fixedlookup>
<filtertextoption>In</filtertextoption>
</field>
...
</fieldlist>
<actions>
</actions>
</summary> |
Expand | ||
---|---|---|
| ||
|
Defining Dashboard Components in Metadata
...