Query results feature set to a brand new Features set

Discussion created by alex92190 on May 2, 2014
Latest reply on Jun 4, 2014 by alex92190
Hi all,
Here what I am trying to do:
1) My overall goal is to query an extent and to extract data by this extent. I can successfully achieve the first part.

2) Here is my issue: The Dynamic layer queried has a schema that wont work with the GP "Extract data". Here are the default fields I need, these fields are the default for any feature set created:

FID ( type: esriFieldTypeOID , alias: FID )
Id ( type: esriFieldTypeInteger , alias: Id )
Shape_Length ( type: esriFieldTypeDouble , alias: Shape_Length )
Shape_Area ( type: esriFieldTypeDouble , alias: Shape_Area )
Features: None.

3) The solution that I am trying to implement is very close to what this person was trying to implement on this thread. My basic understanding of this is to gather all graphics, push them into a brand new feature set and then use it as an AOI.

4) My code that works but return an empty shapefile or values:

function executeQueryTask(county) {
    var county = document.getElementById("sel_county").value        
          var queryTask = new QueryTask("http://webgisdevint1/arcgis/rest/services/Alex_Try/Counties/MapServer/0");
    var query = new Query();
          query.returnGeometry = true;
          query.outFields = ["FMNAME_UC"];
          query.where = "FMNAME_UC = '" + county + "'";
          query.outSpatialReference = map.spatialReference;
    var clipLayers = [];
     if (registry.byId("layer1").get("checked")) {
            if (registry.byId("layer2").get("checked")) {
            if (registry.byId("layer3").get("checked")) {
   if (clipLayers.length === 0) {
               alert("No layers to clip, please select a layer you would like to clip...");
    graphic = new Graphic();
     graphic.geometry = esri.graphicsExtent(;
     var clipFeatureSet = new FeatureSet();
     clipFeature = [];
     dojo.forEach(, function(graphic){
     //if (graphic.geometry.type ="polygon")
              clipFeature.push (graphic);
     clipFeatureSet.features = clipFeature;

    var params = {
               "Layers_to_Clip": clipLayers,
               "Area_of_Interest": clipFeatureSet,
               "Feature_Format": registry.byId("formatBox").get("value")
            domStyle.set(loading, "display", "inline-block");
            gp.submitJob(params, completeCallback, statusCallback, function (error) {
               domStyle.set(loading, "display", "none");

Any idea is more than welcome!