+ Reply to Thread
Results 1 to 2 of 2

Thread: Geoprocessing Task with Feature Set derived from Feature Layer not working

  1. #1
    Shane Bergman
    Join Date
    Feb 2012
    Posts
    2
    Points
    0
    Answers Provided
    0


    0

    Default Geoprocessing Task with Feature Set derived from Feature Layer not working

    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-2351346...ver/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;
    }

  2. #2
    Stephen Lead
    Join Date
    May 2010
    Posts
    772
    Points
    160
    Answers Provided
    31


    0

    Default Re: Geoprocessing Task with Feature Set derived from Feature Layer not working

    Hi Shane,

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

    Quote Originally Posted by sr0bergman View Post
    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:

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

+ Reply to Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts