You need to sign in to do that
Don't have an account?
TechEd_Programmer
Service Console Custom Component - VF Page
Ok.....just need a bit of help to understand what I am doing wrong.
I have all of the attributes I need to display this page in the left subtab sidebar of the service cloud console....I think. I am not sure why it is not showing anything. I have records that should be aggregating and they are not. Can someone tell me why?
Controller:
public class NS_ConsoleCaseChartController { public String strContactID; public String strCaseID; public NS_ConsoleCaseChartController(ApexPages.StandardController stdController){ strCaseID = ApexPages.currentPage().getParameters().get('Id'); } public List<ChartDataItem> getChartData() { List<ChartDataItem> items = new List<ChartDataItem>(); strContactId = string.valueOf(Case.ContactId); AggregateResult[] groupedTasks = [SELECT Type, Count(Id) ID FROM Task WHERE WhoId =: strContactID GROUP BY Type]; for (AggregateResult ar : groupedTasks) { items.add(new ChartDataItem( String.valueOf(ar.get('Type')), Integer.valueOf(ar.get('ID')))); } System.debug(items); return items; } public class ChartDataItem { public String Label {get; set;} public Integer Value {get; set;} public ChartDataItem(String Label, Integer Value) { this.Label = Label; this.Value = Value; } } }
VF Page:
<apex:page standardController="Case" extensions="NS_ConsoleCaseChartController"> <apex:includeScript value="/soap/ajax/26.0/connection.js"/> <apex:includeScript value="/support/console/26.0/integration.js"/> <script type="text/javascript"> function openNewSubtab() { sforce.console.getFocusedPrimaryTabId(Id); } </script> <apex:chart height="195" width="250" data="{!chartData}"> <apex:pieSeries dataField="Value" labelField="Label"/> <apex:legend position="bottom"/> </apex:chart> </apex:page>
I am really trying to figure out what I am missing here. I am new to developing in the Service Cloud Console.
Hi,
none of the Label values can be null or the pie chart will not render, try adding this to you controller;
if (ar.get('Type')==null){
items.add(new ChartDataItem( String.valueOf('Other'), Integer.valueOf(ar.get('ID'))));}
else{
items.add(new ChartDataItem( String.valueOf(ar.get('Type')), Integer.valueOf(ar.get('ID'))));}
Cheers.
All Answers
Hi,
custom console components that sit in the sidebar can just be a visualforce page using the standard controller, no need to reference the service console API unless you wish to interact with the console.
Also, when using a controller extension you cannot reference the object in your controller code like you have 'Case.ContactId', you need to get the record in the extension constructor using stdController.getRecord(). You must also have a reference in the vf to the fields you wish to use in the controller logic, this can be hidden on the page.
Thanks,
J
The vf and extension would look something like this;
VF Page:
Controller extension
Good News is that the debugger shows that my aggregations are working, however the VF page is still not displaying a pic chart in the Service Cloud Console. Any odeas?
Hi,
none of the Label values can be null or the pie chart will not render, try adding this to you controller;
if (ar.get('Type')==null){
items.add(new ChartDataItem( String.valueOf('Other'), Integer.valueOf(ar.get('ID'))));}
else{
items.add(new ChartDataItem( String.valueOf(ar.get('Type')), Integer.valueOf(ar.get('ID'))));}
Cheers.
Thank you very much. that gave me what I needed.