2

Is it possible to create reports and dashboards using Lightning Connect? It looks like it's not supported at the moment.

1 Answer 1

0

Its not possible to use Salesforce Reports and Dashboards currently but all is not lost .

You can use Visualforce Charting to solve your needs .Here is a good blog from engineering team at salesforce to get you started .

Visualforce charting expects a dataset and you can create wrapper objects around external data to achieve your needs

<apex:pageBlock title="SAP Sales Order Report" >
 <apex:pageBlockSection columns="2">
   <apex:pageBlockSectionItem >           
       <apex:chart height="250" width="450" data="{!TotalSales}">
           <apex:axis type="Numeric" position="bottom" fields="Value" title="Total Sales"/>
           <apex:axis type="Category" position="left" fields="Name" title="Customer"/>         
           <apex:barSeries orientation="horizontal" axis="left" xField="Value" yField="Name"/>
       </apex:chart>
     </apex:pageBlockSectionItem>
</apex:pageBlock>

Apex code

public class SalesOrderReportController {

// Declare Lists and Maps
public List SlsOrdRpt { get; set; }
public List CustList {get; set; }
public Map<String, List> SlsOrdMap {get; set; }
public Map TotalCount { get; set; }
public Map TotalNetSum { get; set; }
public Map TotalSum { get; set; }
public List TotalOrderCount { get; set; }
public List TotalSales { get; set; }
public List TotalNetSales { get; set; }

public SalesOrderReportController() {
  // Use a fixed list to start:
   CustList = new List{
     'Asia High tech', 'Advanced Interconnections Corp', 'United Partners',    'Allied Technologies',
     'Chicago Computers', 'County of Solano','Panorama Studios','Sustainable   Audio'};
  // add others, or build a query to populate a list
  // Instantiate the maps
 SlsOrdMap = new Map<String, List>();
 TotalCount = new Map ();
TotalNetSum = new Map ();
TotalSum = new Map ();
TotalOrderCount = new List ();
TotalSales = new List ();
TotalNetSales = new List ();

  // Iterate over the fixed customer list, build the map with keys/ values: 
  for (String clist : CustList){  
    // Load the map, using the iterator for the key and the where clause
    SlsOrdMap.put(clist, SlsOrdRpt = [
       SELECT customerName__c, ExternalId, totalSum__c, currency__c, netSum__c, note__c
       from SalesOrder__x where customerName__c = :clist order by customerName__c ]);

   // Zero out the local accumulator variables
   Decimal LocTotCount = 0;
   Decimal LocTotNetSum = 0;
   Decimal LocTotSum = 0;
   // Iterate over records in each SlsOrdRpt List and do the count/ accumulations
     for (SalesOrder__x SlsOrd : SlsOrdRpt){
    LocTotCount = LocTotCount + 1;
     LocTotNetSum = LocTotNetSum + (Decimal)SlsOrd.netSum__c;
    LocTotSum = LocTotSum + (Decimal)SlsOrd.totalSum__c;

    }
   // Put the Totals into a Map by customer
     TotalCount.put (clist, LocTotCount); 
     TotalNetSum.put (clist, LocTotNetSum);
     TotalSum.put (clist, LocTotSum);
     TotalOrderCount.add (new ChartData (clist, LocTotCount));    
     TotalSales.add (new ChartData (clist, LocTotSum));
     TotalNetSales.add (new ChartData (clist, LocTotNetSum));
   }

 }
 // Wrapper Class for Chart data
    Public Class ChartData {
     Public String Name {get; set; }
     Public Decimal Value {get; set; }

     Public ChartData (String N,Decimal V){
          Name = N;
        Value = V;
    }
   }
 }

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .