AnsweredAssumed Answered

Print Task: cannot read property of 'query' of undefined

Question asked by davidrenz on Feb 16, 2015
Latest reply on Feb 23, 2015 by csergent08

Hello,

 

I am trying to wire up some print functionality on an app that I am building.

I basically just copied the code from the JSAPI samples page ... just to get a sense of how it works,

 

When I click on the "Print" button, it heads off like the samples do, but I get the following error:

js.arcgis.com/3.12/esri/tasks/Geoprocessor.js?1424148233374:14 Uncaught TypeError: Cannot read property 'query' of undefined

 

I am not sure how to resolve this, it is the first time I have used the 10.2 print task.

I have also tried to publish my own templates as a print task and that is getting the same error.

 

Could someone point me in the right direction on this?

 

thx

David

 

Code is below:

 

        doPrint: function() {

            console.log("In the startup for print!");

 

            //esriConfig.defaults.io.alwaysUseProxy = false;

            //esriConfig.defaults.io.proxyUrl = "";

 

            // get print templates from the export web map task

            var printInfo = esriRequest({

                "url": this.printUrl,

                "content": { "f": "json" }

            });

            printInfo.then(this.handlePrintInfo, this.handleError);

        },

 

        handlePrintInfo: function (resp) {

 

            var layoutTemplate, templateNames, mapOnlyIndex, templates;

            layoutTemplate = arrayUtils.filter(resp.parameters, function (param, idx) {

                return param.name === "Layout_Template";

            });

 

            if (layoutTemplate.length === 0) {

                console.log("print service parameters name for templates must be \"Layout_Template\"");

                return;

            }

            templateNames = layoutTemplate[0].choiceList;

 

            // remove the MAP_ONLY template then add it to the end of the list of templates

            mapOnlyIndex = arrayUtils.indexOf(templateNames, "MAP_ONLY");

            if (mapOnlyIndex > -1) {

                var mapOnly = templateNames.splice(mapOnlyIndex, mapOnlyIndex + 1)[0];

                templateNames.push(mapOnly);

            }

 

            // create a print template for each choice

            templates = arrayUtils.map(templateNames, function (ch) {

                var plate = new PrintTemplate();

                plate.layout = plate.label = ch;

                plate.preserveScale = true;

                plate.format = "PDF";

                plate.layoutOptions = {

                    "authorText": "Made by:  Esri's JS API Team",

                    "copyrightText": "<copyright info here>",

                    "legendLayers": [],

                    "titleText": "Pool Permits",

                    "scalebarUnit": "Miles"

                };

                return plate;

            });

 

            // create the print dijit

            var printer = new Print({

                "map": global.MAP,  // ---> yes, I know <sigh!>

                "templates": templates,

                url: this.printUrl

            }, dom.byId("print_button"));

 

            try {

                printer.startup();

            }

            catch (ex) {

                console.log(ex.message);

            }

 

            printer.on('print-start', function () {

                console.log('The print operation has started');

            });

 

            printer.on('print-complete', function (evt) {

                console.log('The url to the print image is : ' + evt.result.url);

            });

 

        },

Outcomes