BA Report Widget 2.4 - Problem using the USACensus2010 activedataset??

09-08-2011 01:19 PM
New Contributor III

I am working on some modifications to the BA Report Widget to add the ability for my users to access the Census 2010 Profile Report in addition to the other included reports for our subscription.

Short Problem Description:

The code works with the USA dataset but the report request errors out when referencing the USACensus2010dataset.


When the code is referencing the "USA" dataset, it all works perfectly.  The dropdown populates with the report names returned from the GetReportTemplates task, I can draw my geography, and when I click run report - I get my report.

When I change the activeDatasetID to reference the USACensus2010, it does not work perfectly.
The dropdown populates correctly with the single Census 2010 profile report returned from the GetReportTemplates task, I can draw my geography, but when I click run report - I get an error rather than a report.

Here is the first function to populate the drop down list of report titles. This runs fine and is used to populate the dropdown list:

private function getReportTemplatesTask() : void 
  lblGuide.text = "Task is executing. Please wait.";
  var getReportTemplatesTask : GetReportTemplatesTask = new GetReportTemplatesTask(_baClient);
//Added the activeDatasetID line to be able to change to the USACensus2010 dataset
  getReportTemplatesTask.activeDatasetID = "USACensus2010"
  //getReportTemplatesTask.activeDatasetID = "USA"
  getReportTemplatesTask.execute(new mx.rpc.Responder(reportTemplatesResultHandler, reportTemplatesFaultHandler));


I select the name of the only report from the drop down list populated by the code above

Draw my polygon on the map

Click Run Report - it chugs for a bit and then errors out with a "can't reference Null object" error

From what I can tell, the event object that the resultHandler receives from the ExecuteReportTask function is empty but I do not understand why it is empty.  Is there documentation or an example of the difference in the request structure for the USA vs the USACensus2010 reports? The code that launches from the "Run Report" is shown below.  It works great with the USA dataset but not the USACensus2010 dataset.

   private function executeReportTask(polygon : Polygon) : void 
    if (polygon)  
     lblGuide.text = "Task is executing. Please wait.";
      * Create summary reports task parameters
     var params:SummaryReportsParameters = new SummaryReportsParameters();
      * create trade areas. 
      * Note: trade areas can also be defined as standard layers instead of a feature set. Example:
      * var tradeAreas:Boundaries = new Boundaries();
      * var id:String = "US.ZIP5";
      * var geographyIDs:Array = ["92373","92374"];
      * tradeAreas.standardLayer = new StandardLayer(id, geographyIDs);
      * params.boundaries = tradeAreas; 
     var features:Array = new Array();
     var feature:Graphic = new Graphic(polygon);
     feature.attributes = {
      "AREA_ID": "custom1",
      "AREA_DESC": "Custom map drawn polygon",
      "STOREID": "1"
     var featureSet:FeatureSet = new FeatureSet(features);
     featureSet.geometryType = Geometry.POLYGON;
     featureSet.spatialReference = polygon.spatialReference;
     // package FeatureSet as a Boundaries object
     params.boundaries = new Boundaries(featureSet);
     // one or more reports can be specified
     var reportOptions:ReportOptions = new ReportOptions();
     // see GetReportTemplates for a list of available report templates
     var rpt:ReportTemplateInfo = this.reportTypeCombo.selectedItem as ReportTemplateInfo;
     if(rpt != null)
     reportOptions.templateName =;
     reportOptions.format = "PDF";
     // customize report headers
     var reportHeader : ReportHeader = new ReportHeader("Generated by Infomentum Online");
     reportHeader.locationName = "Summary Reports";
     reportHeader.address1 = "Powered By ESRI Business Analyst";
     reportHeader.address2 = "";
     // Logo must be available to ESRI BAO report service - hence the public URL
     reportHeader.customLogo = "";
     reportOptions.header = reportHeader;
     params.reportOptions = [reportOptions];
     //  We only need the output report.  We don't need the output geometry
     //  because we already have it on the client.
     var outputTypes:OutputTypes = new OutputTypes();
     outputTypes.getReport = true;
     params.outputTypes = outputTypes;
     var summaryReportsTask : SummaryReportsTask = new SummaryReportsTask(_baClient);
     summaryReportsTask.execute(params, new mx.rpc.Responder(resultHandler, faultHandler));
     {"Please select a report to execute");
    {"Please draw a custom polygon on the map before executing this task");
    * Result handler for the successful completion of the task execution. 
   private function resultHandler(event:BATaskCompletedEvent):void {
    var taskResultOutput : TaskResultOutput = event.result as TaskResultOutput;
    var myCount:uint = taskResultOutput.reports.length;
    var reportInfo : ReportInfo = taskResultOutput.reports[0];
    _reportUrl = reportInfo.url;
    lblGuide.text = "Task complete. " +
     "The summary report has been generated and is ready for download."
    navigateToURL(new URLRequest(_reportUrl), "_blank");

I just don't know why and as of yet have not found much documentation on accessing this report via the BAO API.  Thanks for reading this far and any assistance would be much appreciated!!!



Greenville, SC
0 Kudos
1 Reply
New Contributor
Hi Amy,

No reports are getting returned from the SummaryReportsTask since you are requesting the 'census2010_profile' report from the default dataset, which currently is the USA dataset by default and not the USACensus2010 dataset.

You need to explicitly set the activeDatasetID to USACensus2010 in the SummaryReportsTask also since setting it only on the GetReportTemplatesTask will just return the report templates in the USACensus2010 dataset but it doesn't know anything about the SummaryReportsTask. In general, you have to explicitly set the activeDatasetID for any task you are using since each of these requests sent to the underlying Business Analyst Online REST services are unique.

You can refer to this item under the Business Analyst Online API for Flex - What's New in 2.1 page under

0 Kudos