1 Reply Latest reply on Aug 11, 2013 1:40 AM by stevel

    Geoprocessing Task with Feature Set derived from Feature Layer not working

    sr0bergman
      I have a simple geoprocessing service written in python that converts a table to a CSV file.  It works fine in ArcMap and I can get it to work in Javascript when the input data is set as a constant value or selected form the layer list.  When I try to run it with user defined input (a Feature Set derived from a Feature Layer) the tool fails.  I am at a complete loss! 

      The service is published at: http://arcgis-tamarackags101-235134627.us-west-2.elb.amazonaws.com/arcgis/rest/services/Emerson/TableToCSV_FS3/GPServer/TableToCSV

      Here is my code:

      function exportAll(){
           var query = new esri.tasks.Query();
        query.where = "1 = 1";
        query.outFields = ["*"];
        //parcelsFS is my Feature Service Layer
        parcelsFS.queryFeatures(query, function (features) {
        var inputFeatures = new esri.tasks.FeatureSet();
              inputFeatures = features.features;
        var params= { "Table_Name":inputFeatures};
        gpTask.submitJob(params, completeCallback , statusCallback,function(error){
                //alert(error);
                //esri.hide(loading);
         });
        });
      }

      function completeCallback(jobInfo){
              if(jobInfo.jobStatus !== "esriJobFailed"){
                gpTask.getResultData(jobInfo.jobId,"Output_CSV", downloadFile);
              }
            }
            function statusCallback(jobInfo) {
              var status = jobInfo.jobStatus;
              if(status === "esriJobFailed"){
                alert(status);
                //esri.hide(loading);
              }
              else if (status === "esriJobSucceeded"){
                //esri.hide(loading);
              }
            }
            function downloadFile(outputFile){
              map.graphics.clear();
              var theurl = outputFile.value.url;
         console.log(theurl); 
              window.location = theurl;
            }
        • Re: Geoprocessing Task with Feature Set derived from Feature Layer not working
          stevel
          Hi Shane,

          A quick tip is to surround your code in CODE tags (the # icon) to avoid stripping off the formatting.

          I can get it to work in Javascript when the input data is set as a constant value or selected form the layer list. When I try to run it with user defined input (a Feature Set derived from a Feature Layer) the tool fails. I am at a complete loss!
           

          Try putting a breakpoint in this section and stepping through line-by-line:

              parcelsFS.queryFeatures(query, function (features) {
                  var inputFeatures = new esri.tasks.FeatureSet();
                  inputFeatures = features.features;
                  var params= { "Table_Name":inputFeatures};    
                  gpTask.submitJob(params, completeCallback , statusCallback,function(error){
                      //alert(error);
                      //esri.hide(loading);
                  });
              });
          


          and verify that what you're doing here makes sense in all instances. If you're sometimes inputting a featureLayer, and at other times a featureSet, you may find that this is causing the problem.

          Steve