Problem getting result of geoprocessing task to display on web map

Discussion created by jodicross on May 7, 2014
Latest reply on May 7, 2014 by jodicross
I'm new to JavaScript and using geoprocessing services, so maybe this is simple syntax mistake, but I've spent numerous days trying to figure it out and I'm completely stuck.

I???m having problems getting the result of our geoprocessing service to display in our web application. The service is a simple select by attributes task that outputs a polygon feature (inputs are a choice list of feature classes, and an SQL statement). I???ve been able to return the polygon geometry as a graphic (which I know from console log statements) but when I try to add the graphic to the map nothing happens. Does anyone have any ideas? They would be much appreciated!!

    function(dom, array, locale, parser, registry,
             domUtils, Map, Graphic, GraphicsLayer, FeatureLayer, Geoprocessor, FeatureSet){
      var gpServiceUrl= "http://<server>/arcgis/rest/services/Pipelines/ExportHazardCatchment/GPServer/Select";

      var map = new Map("map",{
        basemap: "streets",
        center: [-122.81, 45.466],
        zoom: 8

      //Run the gp task 
      var gp = new Geoprocessor(gpServiceUrl);
      function selectCatchment(){
        var client = dom.byId('clientList').value;
        var params = {"input_features": client, 
          "output_feature_class": JSON,
          "where_clause": buildDefinitionQuery()
        gp.submitJob(params, gpJobComplete, gpJobStatus, gpJobFailed);

    function gpJobComplete(jobInfo) {
    console.log("in JobComplete");
    var status = jobInfo.jobStatus;
    if (status === "esriJobSucceeded"){
           console.log("success, jobId:" + jobInfo.jobId);
           var results = gp.getResultData(jobInfo.jobId, "out_feature_class", onTaskResultComplete);
           console.log("past getResultsData");
    function onTaskResultComplete(paramResult) {
      // Retrieve the value of the parameter from the paramresult
      var featureSet = paramResult.value;
      // Create a symbol based on the geometry. 
      var simplePolySymbol = new esri.symbol.SimpleFillSymbol();
      simplePolySymbol.setOutline(new esri.symbol.SimpleLineSymbol(
                  new dojo.Color([0,0,0,0.5]), 1));
      simplePolySymbol.setColor(new dojo.Color([255,0,0,0.7]));
       var gra = new Graphic(featureSet);

      function gpJobStatus(jobInfo){

      function gpJobFailed(error){
     alert("Error:"+ error); 

      function buildDefinitionQuery(){
        var defQuery;
        //get input info from form and build definition expression
        var hazardIDs = dojo.byId('query').value;
        defQuery = "\"HazardID\"=" + hazardIDs;
        return defQuery;
    app = {
        selectCatchment: selectCatchment
      return app;

Here is a screen shot of the page from our gp task:[ATTACH=CONFIG]33661[/ATTACH]