Error When Creating Report with Report dijit

1962
14
Jump to solution
05-06-2020 06:55 AM
joerodmey
MVP Alum

I have tried to create a report using the report dijit and keep getting the following error "Create widget error widgets/Report/Widget". I've explored the following example with no luck Create a custom widget using the Report dijit—Web AppBuilder for ArcGIS (Developer Edition) | ArcGIS... 

Below is my widget.js:

define(['dojo/_base/declare', 'jimu/BaseWidget', 'jimu/dijit/Report', 'jimu/dijit/PageUtils'],
function(declare, BaseWidget, Report, PageUtils) {
  //To create a widget, you need to derive from BaseWidget.
  return declare([BaseWidget], {
    // DemoWidget code goes here

    //please note that this property is be set by the framework when widget is loaded.
    //templateString: template,

    baseClass: 'jimu-widget-report',

    postCreate: function() {
      this.inherited(arguments);
      console.log('postCreate');
    },

    startup: function() {
      this.inherited(arguments);
	  
	  this.report = new Report ({
		  footNotes: "Reported Generated by Terracon"
		  printTaskUrl: "http://utility.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task",
		  reportLayout: {
			  "pageSize": PageUtils.PageSizes.A4,
			  "orientation": PageUtils.Orientation.Landscape
	  }}
	  });
	  
	  console.log('startup');
	  
	
 
}}

_onBtnPrintClicked: function(){
		var printData = [
		{
		  addPageBreak: true,
		  type: "map",
		  map: this.map
		},
		{
		  title: "List of parks",
		  addPageBreak: false,
		  type: "table",
		  tableCols: 3,
		  data: {
			showRowIndex: false,
			rows:  [["Brookside Park", "1630 Brookside Avenue, Redlands, CA 92373", "34.045347, -117.209909"],
			        ["Crafton Park", "Wabash Ave & Independence Ave, Redlands, CA 92374", "34.060946, -117.140118"],
					["Ford Park", "Parkford Dr & Redlands Blvd, Redlands, CA 92374", "34.043828, -117.160692"],
					["Prospect Park", "352 Prospect Dr., Redlands, CA 92373", "34.039145, -117.172582"],
					["Sylvan Park", "601 N University St, Redlands, CA 92374", "34.059977, -117.168179"]],
			cols: ["Name", "Address", "Lat/Lon"]
		  }
		},
		{
			title: "Photos",
			type: "html",
			data: '<div style="height: 450px;"><div style="width: 250px; margin-left: 10px; float: left;"><div><img style="width: 250px; height: 200px; float: left;" src="http://cityofredlands.org/sites/default/files/rda/Landmarks/brookside.jpg" /></div><div style="text-align:center; margin-bottom: 10px;">Brookside Park</div></div>'+
			      '<div style="width: 250px; margin-left: 10px; float: left;"><div><img style="width: 250px; height: 200px; float: left;" src="http://cityofredlands.org/sites/default/files/rda/Landmarks/Crafton.jpg" /></div><div style="text-align:center; margin-bottom: 10px;">Crafton Park</div></div>'+
				  '<div style="width: 250px; margin-left: 10px; float: left;"><div><img style="width: 250px; height: 200px; float: left;" src="http://cityofredlands.org/sites/default/files/rda/Landmarks/ford-park.jpg" /></div><div style="text-align:center; margin-bottom: 10px;">Ford Park</div></div>'+
				  '<div style="width: 250px; margin-left: 10px; float: left; clear:left;"><div><img style="width: 250px; height: 200px; float: left;" src="http://cityofredlands.org/sites/default/files/rda/Landmarks/Prospect%20park.jpg" /></div><div style="text-align:center; margin-bottom: 10px;">Prospect Park</div></div>'+
				  '<div style="width: 250px; margin-left: 10px; float: left;"><div><img style="width: 250px; height: 200px; float: left;" src="http://cityofredlands.org/sites/default/files/rda/Landmarks/Sylvan%20Park.jpg" /></div><div style="text-align:center; margin-bottom: 10px;">Sylvan Park</div></div></div>'
		}];
        this.report.print("Redlands Parks", printData);
      },

Any ideas?

Thanks

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

In that case, you needed closing braces and parentheses at the end (lines 68 and 69). In addition, you were missing a comma in line 21.

define(['dojo/_base/declare', 'jimu/BaseWidget', 'jimu/dijit/Report', 'jimu/dijit/PageUtils'],
  function (declare, BaseWidget, Report, PageUtils) {
    //To create a widget, you need to derive from BaseWidget.
    return declare([BaseWidget], {
      // DemoWidget code goes here

      //please note that this property is be set by the framework when widget is loaded.
      //templateString: template,

      baseClass: 'jimu-widget-report',

      postCreate: function () {
        this.inherited(arguments);
        console.log('postCreate');
      },

      startup: function () {
        this.inherited(arguments);

        this.report = new Report({
          footNotes: "Reported Generated by Terracon",
          printTaskUrl: "http://utility.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task",
          reportLayout: {
            "pageSize": PageUtils.PageSizes.A4,
            "orientation": PageUtils.Orientation.Landscape
          }
        });

        console.log('startup');
      },

      _onBtnPrintClicked: function () {
        var printData = [
          {
            addPageBreak: true,
            type: "map",
            map: this.map
          },
          {
            title: "List of parks",
            addPageBreak: false,
            type: "table",
            tableCols: 3,
            data: {
              showRowIndex: false,
              rows: [["Brookside Park", "1630 Brookside Avenue, Redlands, CA 92373", "34.045347, -117.209909"],
              ["Crafton Park", "Wabash Ave & Independence Ave, Redlands, CA 92374", "34.060946, -117.140118"],
              ["Ford Park", "Parkford Dr & Redlands Blvd, Redlands, CA 92374", "34.043828, -117.160692"],
              ["Prospect Park", "352 Prospect Dr., Redlands, CA 92373", "34.039145, -117.172582"],
              ["Sylvan Park", "601 N University St, Redlands, CA 92374", "34.059977, -117.168179"]],
              cols: ["Name", "Address", "Lat/Lon"]
            }
          },
          {
            title: "Photos",
            type: "html",
            data: '<div style="height: 450px;"><div style="width: 250px; margin-left: 10px; float: left;"><div><img style="width: 250px; height: 200px; float: left;" src="http://cityofredlands.org/sites/default/files/rda/Landmarks/brookside.jpg" /></div><div style="text-align:center; margin-bottom: 10px;">Brookside Park</div></div>' +
              '<div style="width: 250px; margin-left: 10px; float: left;"><div><img style="width: 250px; height: 200px; float: left;" src="http://cityofredlands.org/sites/default/files/rda/Landmarks/Crafton.jpg" /></div><div style="text-align:center; margin-bottom: 10px;">Crafton Park</div></div>' +
              '<div style="width: 250px; margin-left: 10px; float: left;"><div><img style="width: 250px; height: 200px; float: left;" src="http://cityofredlands.org/sites/default/files/rda/Landmarks/ford-park.jpg" /></div><div style="text-align:center; margin-bottom: 10px;">Ford Park</div></div>' +
              '<div style="width: 250px; margin-left: 10px; float: left; clear:left;"><div><img style="width: 250px; height: 200px; float: left;" src="http://cityofredlands.org/sites/default/files/rda/Landmarks/Prospect%20park.jpg" /></div><div style="text-align:center; margin-bottom: 10px;">Prospect Park</div></div>' +
              '<div style="width: 250px; margin-left: 10px; float: left;"><div><img style="width: 250px; height: 200px; float: left;" src="http://cityofredlands.org/sites/default/files/rda/Landmarks/Sylvan%20Park.jpg" /></div><div style="text-align:center; margin-bottom: 10px;">Sylvan Park</div></div></div>'
          }];
        this.report.print("Redlands Parks", printData);

      }


    });
  });

View solution in original post

14 Replies
KenBuja
MVP Esteemed Contributor

Is there an extra bracket in line 26? And line 33?

0 Kudos
joerodmey
MVP Alum

I played around with brackets and moved the btn function into the main function and still no luck. Updated code:

define(['dojo/_base/declare', 'jimu/BaseWidget', 'jimu/dijit/Report', 'jimu/dijit/PageUtils'],
function(declare, BaseWidget, Report, PageUtils) {
  //To create a widget, you need to derive from BaseWidget.
  return declare([BaseWidget], {
    // DemoWidget code goes here

    //please note that this property is be set by the framework when widget is loaded.
    //templateString: template,

    baseClass: 'jimu-widget-report',

    postCreate: function() {
      this.inherited(arguments);
      console.log('postCreate');
    },

    startup: function() {
      this.inherited(arguments);
	  
	  this.report = new Report ({
		  footNotes: "Reported Generated by Terracon"
		  printTaskUrl: "http://utility.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task",
		  reportLayout: {
			  "pageSize": PageUtils.PageSizes.A4,
			  "orientation": PageUtils.Orientation.Landscape
	  }
	  });
	  
	  console.log('startup');
	  
	  
	_onBtnPrintClicked: function(){
		var printData = [
		{
		  addPageBreak: true,
		  type: "map",
		  map: this.map
		},
		{
		  title: "List of parks",
		  addPageBreak: false,
		  type: "table",
		  tableCols: 3,
		  data: {
			showRowIndex: false,
			rows:  [["Brookside Park", "1630 Brookside Avenue, Redlands, CA 92373", "34.045347, -117.209909"],
			        ["Crafton Park", "Wabash Ave & Independence Ave, Redlands, CA 92374", "34.060946, -117.140118"],
					["Ford Park", "Parkford Dr & Redlands Blvd, Redlands, CA 92374", "34.043828, -117.160692"],
					["Prospect Park", "352 Prospect Dr., Redlands, CA 92373", "34.039145, -117.172582"],
					["Sylvan Park", "601 N University St, Redlands, CA 92374", "34.059977, -117.168179"]],
			cols: ["Name", "Address", "Lat/Lon"]
		  }
		},
		{
			title: "Photos",
			type: "html",
			data: '<div style="height: 450px;"><div style="width: 250px; margin-left: 10px; float: left;"><div><img style="width: 250px; height: 200px; float: left;" src="http://cityofredlands.org/sites/default/files/rda/Landmarks/brookside.jpg" /></div><div style="text-align:center; margin-bottom: 10px;">Brookside Park</div></div>'+
			      '<div style="width: 250px; margin-left: 10px; float: left;"><div><img style="width: 250px; height: 200px; float: left;" src="http://cityofredlands.org/sites/default/files/rda/Landmarks/Crafton.jpg" /></div><div style="text-align:center; margin-bottom: 10px;">Crafton Park</div></div>'+
				  '<div style="width: 250px; margin-left: 10px; float: left;"><div><img style="width: 250px; height: 200px; float: left;" src="http://cityofredlands.org/sites/default/files/rda/Landmarks/ford-park.jpg" /></div><div style="text-align:center; margin-bottom: 10px;">Ford Park</div></div>'+
				  '<div style="width: 250px; margin-left: 10px; float: left; clear:left;"><div><img style="width: 250px; height: 200px; float: left;" src="http://cityofredlands.org/sites/default/files/rda/Landmarks/Prospect%20park.jpg" /></div><div style="text-align:center; margin-bottom: 10px;">Prospect Park</div></div>'+
				  '<div style="width: 250px; margin-left: 10px; float: left;"><div><img style="width: 250px; height: 200px; float: left;" src="http://cityofredlands.org/sites/default/files/rda/Landmarks/Sylvan%20Park.jpg" /></div><div style="text-align:center; margin-bottom: 10px;">Sylvan Park</div></div></div>'
		}];
        this.report.print("Redlands Parks", printData);
 
}


      }
0 Kudos
KenBuja
MVP Esteemed Contributor

Try this. I've added line 30, a closing brace for the startup function and a comma. You need commas to separate the functions. What type of IDE are you using? A good one will highlight the paired brackets, braces, and parentheses, which is quite helpful in debugging.

define(['dojo/_base/declare', 'jimu/BaseWidget', 'jimu/dijit/Report', 'jimu/dijit/PageUtils'],
function(declare, BaseWidget, Report, PageUtils) {
  //To create a widget, you need to derive from BaseWidget.
  return declare([BaseWidget], {
    // DemoWidget code goes here

    //please note that this property is be set by the framework when widget is loaded.
    //templateString: template,

    baseClass: 'jimu-widget-report',

    postCreate: function() {
      this.inherited(arguments);
      console.log('postCreate');
    },

    startup: function() {
      this.inherited(arguments);
       
       this.report = new Report ({
            footNotes: "Reported Generated by Terracon"
            printTaskUrl: "http://utility.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task",
            reportLayout: {
                 "pageSize": PageUtils.PageSizes.A4,
                 "orientation": PageUtils.Orientation.Landscape
       }
       });
       
       console.log('startup');
    }, 
       
     _onBtnPrintClicked: function(){
          var printData = [
          {
            addPageBreak: true,
            type: "map",
            map: this.map
          },
          {
            title: "List of parks",
            addPageBreak: false,
            type: "table",
            tableCols: 3,
            data: {
               showRowIndex: false,
               rows:  [["Brookside Park", "1630 Brookside Avenue, Redlands, CA 92373", "34.045347, -117.209909"],
                       ["Crafton Park", "Wabash Ave & Independence Ave, Redlands, CA 92374", "34.060946, -117.140118"],
                         ["Ford Park", "Parkford Dr & Redlands Blvd, Redlands, CA 92374", "34.043828, -117.160692"],
                         ["Prospect Park", "352 Prospect Dr., Redlands, CA 92373", "34.039145, -117.172582"],
                         ["Sylvan Park", "601 N University St, Redlands, CA 92374", "34.059977, -117.168179"]],
               cols: ["Name", "Address", "Lat/Lon"]
            }
          },
          {
               title: "Photos",
               type: "html",
               data: '<div style="height: 450px;"><div style="width: 250px; margin-left: 10px; float: left;"><div><img style="width: 250px; height: 200px; float: left;" src="http://cityofredlands.org/sites/default/files/rda/Landmarks/brookside.jpg" /></div><div style="text-align:center; margin-bottom: 10px;">Brookside Park</div></div>'+
                     '<div style="width: 250px; margin-left: 10px; float: left;"><div><img style="width: 250px; height: 200px; float: left;" src="http://cityofredlands.org/sites/default/files/rda/Landmarks/Crafton.jpg" /></div><div style="text-align:center; margin-bottom: 10px;">Crafton Park</div></div>'+
                      '<div style="width: 250px; margin-left: 10px; float: left;"><div><img style="width: 250px; height: 200px; float: left;" src="http://cityofredlands.org/sites/default/files/rda/Landmarks/ford-park.jpg" /></div><div style="text-align:center; margin-bottom: 10px;">Ford Park</div></div>'+
                      '<div style="width: 250px; margin-left: 10px; float: left; clear:left;"><div><img style="width: 250px; height: 200px; float: left;" src="http://cityofredlands.org/sites/default/files/rda/Landmarks/Prospect%20park.jpg" /></div><div style="text-align:center; margin-bottom: 10px;">Prospect Park</div></div>'+
                      '<div style="width: 250px; margin-left: 10px; float: left;"><div><img style="width: 250px; height: 200px; float: left;" src="http://cityofredlands.org/sites/default/files/rda/Landmarks/Sylvan%20Park.jpg" /></div><div style="text-align:center; margin-bottom: 10px;">Sylvan Park</div></div></div>'
          }];
        this.report.print("Redlands Parks", printData);
 
    }


}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
joerodmey
MVP Alum

Tried this but still the same error

0 Kudos
KenBuja
MVP Esteemed Contributor

Are there any errors in the console?

0 Kudos
joerodmey
MVP Alum

It says missing } after property list

note: { opened at line 35, column 33

it also says TypeError: clazz is not a constructor

0 Kudos
KenBuja
MVP Esteemed Contributor

Can you post the entire script?

0 Kudos
joerodmey
MVP Alum

That is the entire widget.js file for this widget

0 Kudos
KenBuja
MVP Esteemed Contributor

In that case, you needed closing braces and parentheses at the end (lines 68 and 69). In addition, you were missing a comma in line 21.

define(['dojo/_base/declare', 'jimu/BaseWidget', 'jimu/dijit/Report', 'jimu/dijit/PageUtils'],
  function (declare, BaseWidget, Report, PageUtils) {
    //To create a widget, you need to derive from BaseWidget.
    return declare([BaseWidget], {
      // DemoWidget code goes here

      //please note that this property is be set by the framework when widget is loaded.
      //templateString: template,

      baseClass: 'jimu-widget-report',

      postCreate: function () {
        this.inherited(arguments);
        console.log('postCreate');
      },

      startup: function () {
        this.inherited(arguments);

        this.report = new Report({
          footNotes: "Reported Generated by Terracon",
          printTaskUrl: "http://utility.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task",
          reportLayout: {
            "pageSize": PageUtils.PageSizes.A4,
            "orientation": PageUtils.Orientation.Landscape
          }
        });

        console.log('startup');
      },

      _onBtnPrintClicked: function () {
        var printData = [
          {
            addPageBreak: true,
            type: "map",
            map: this.map
          },
          {
            title: "List of parks",
            addPageBreak: false,
            type: "table",
            tableCols: 3,
            data: {
              showRowIndex: false,
              rows: [["Brookside Park", "1630 Brookside Avenue, Redlands, CA 92373", "34.045347, -117.209909"],
              ["Crafton Park", "Wabash Ave & Independence Ave, Redlands, CA 92374", "34.060946, -117.140118"],
              ["Ford Park", "Parkford Dr & Redlands Blvd, Redlands, CA 92374", "34.043828, -117.160692"],
              ["Prospect Park", "352 Prospect Dr., Redlands, CA 92373", "34.039145, -117.172582"],
              ["Sylvan Park", "601 N University St, Redlands, CA 92374", "34.059977, -117.168179"]],
              cols: ["Name", "Address", "Lat/Lon"]
            }
          },
          {
            title: "Photos",
            type: "html",
            data: '<div style="height: 450px;"><div style="width: 250px; margin-left: 10px; float: left;"><div><img style="width: 250px; height: 200px; float: left;" src="http://cityofredlands.org/sites/default/files/rda/Landmarks/brookside.jpg" /></div><div style="text-align:center; margin-bottom: 10px;">Brookside Park</div></div>' +
              '<div style="width: 250px; margin-left: 10px; float: left;"><div><img style="width: 250px; height: 200px; float: left;" src="http://cityofredlands.org/sites/default/files/rda/Landmarks/Crafton.jpg" /></div><div style="text-align:center; margin-bottom: 10px;">Crafton Park</div></div>' +
              '<div style="width: 250px; margin-left: 10px; float: left;"><div><img style="width: 250px; height: 200px; float: left;" src="http://cityofredlands.org/sites/default/files/rda/Landmarks/ford-park.jpg" /></div><div style="text-align:center; margin-bottom: 10px;">Ford Park</div></div>' +
              '<div style="width: 250px; margin-left: 10px; float: left; clear:left;"><div><img style="width: 250px; height: 200px; float: left;" src="http://cityofredlands.org/sites/default/files/rda/Landmarks/Prospect%20park.jpg" /></div><div style="text-align:center; margin-bottom: 10px;">Prospect Park</div></div>' +
              '<div style="width: 250px; margin-left: 10px; float: left;"><div><img style="width: 250px; height: 200px; float: left;" src="http://cityofredlands.org/sites/default/files/rda/Landmarks/Sylvan%20Park.jpg" /></div><div style="text-align:center; margin-bottom: 10px;">Sylvan Park</div></div></div>'
          }];
        this.report.print("Redlands Parks", printData);

      }


    });
  });