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



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: 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?





Code is below:


        doPrint: function() {

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


            // = false;

            // = "";


            // 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 === "Layout_Template";



            if (layoutTemplate.length === 0) {

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



            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];




            // create a print template for each choice

            templates =, 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 {



            catch (ex) {




            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);