Select to view content in your preferred language

method failed error

1420
0
05-23-2012 12:12 PM
danbecker
Frequent Contributor
I occasionally get these errors in the manager error log:

Method failed.HRESULT = 0x80041251 : This is a FACILITY_ITF error that is specific to the interface that returned this error. See the documentation of the interface that returned this error for information about this HRESULT.


Method failed.HRESULT = 0x80070057 : The parameter is incorrect. .



The error is recorded when using the identifyTask is fired, which in turn triggers a bunch of relationshipQueries. I put my code below.
Usually, clearing rest Cache, restarting the service and refreshing the browser clears the problem.

Anyone know what could be happening? Thanks!

function executeIdentifyTask(evt) {
    identifyParams.layerIds = lids;           
        identifyParams.width  = map.width;
        identifyParams.height = map.height;
        identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_VISIBLE;    
        identifyParams.geometry = anchorPt;
        identifyParams.mapExtent = map.extent;
       
        var deferred = identifyTask.execute(identifyParams);
  
        deferred.addCallback(function(response) {

            return dojo.map(response, function(result) {
            var feature = result.feature;
            feature.attributes.layerName = result.layerName;
   
   //setup case switches for each layer
      switch(result.layerName){
                                case "Facilities":
     var x = feature.geometry.x;
     var y = feature.geometry.y;
        var featObjId = feature.attributes.OBJECTID;
     //" + getZip(feature.attributes.zip) + "
     var tmpCont = "<span>{address}<br/>{facil_location}<br/>" + getZip(feature.attributes.zip) + "Acres: {acres}<br/><br/></span><div id='graphic" + featObjId + "'>{graphicCmdData}</div>";
        var relatedBranch = new esri.tasks.RelationshipQuery();
     relatedBranch.outFields = ["*"];
     relatedBranch.relationshipId = 0; //fac -to- Branch relationshipID
     relatedBranch.objectIds = [featObjId];
                facSel.queryRelatedFeatures(relatedBranch, function(relatedBranches) {
      var branchFound = false;
      if(relatedBranches.hasOwnProperty(featObjId) == true){
       branchFound = true;
       var branchSet = relatedBranches[featObjId];
       var cmdBranch = dojo.map(branchSet.features, function(feature){
        return feature.attributes;
       })
       //console.log(cmdBranch);
      }
      //regardless of whether a branch is found or not, we have to run the cmdMain relationship query
      //the parent is still fac, no advantage of the parent being branch since cmcMain query has to be run regardless
      //fac - branch - cmdMain - cmdSub <--sometimes
      //fac - cmdMain - cmdSub <-- sometimes   
      var relatedQuery = new esri.tasks.RelationshipQuery();
            relatedQuery.outFields = ["*"];
            relatedQuery.relationshipId = 1; //fac -to- cmdMain relationshipIP
            relatedQuery.objectIds = [featObjId];
      //rather then listen for "OnSelectionComplete" we are using the queryRelatedFeatures callback function
      facSel.queryRelatedFeatures(relatedQuery, function(relatedRecords) {
       var data = []; //this holds our branch - cmdMain - cmdSub data
       //if any cmdMain records were found, relatedRecords object will have a property == to the       OBJECTID of the clicked feature
       //i.e. if cmdMain records are found, true will be returned; and continue with finding cmdSub records
       if(relatedRecords.hasOwnProperty(featObjId) == true){
        var fset = relatedRecords[featObjId]
        var cmdMain = dojo.map(fset.features, function(feature) {
         return feature.attributes;
        })
        //we need to fill an array with the objectids of the returned cmdMain records
        //the length of this list == total number of mainCmd records returned for the clicked facility
        objs = [];
        for (var k in cmdMain){
         var o = cmdMain;
         objs.push(o.OBJECTID)      
        }
        //third relationship query to find records related to cmdMain (cmdSub)
        var subQuery = new esri.tasks.RelationshipQuery();
        subQuery.outFields = ["*"];
        subQuery.relationshipId = 2; //cmdMin -to- CmdSub relationshipId
        subQuery.objectIds = [objs]
        subTbl.queryRelatedFeatures(subQuery)
        //we are using the queryRelatedFeatures callback method function(subRecords) fires when the subQuery is complete
        //a dojo.connect(subTbl,onSelectionComplete, function) was initially used here but it wasn't disconnecting, so it would fire multiple times
        subTbl.queryRelatedFeatures(subQuery, function(subRecords){
         //subRecords is an object where each property is the objectid of a cmdMain record
         //if a cmdRecord objectid is present in subRecords property, cmdMain has sub records
         //we no longer need these objectids, so we'll remove them and put the array into cmdsub
         var cmdSub = [];
         for (id in subRecords){
          dojo.forEach(subRecords[id].features, function(rec){
           cmdSub.push(rec.attributes)
          })
         }
         var j = cmdSub.length;
         var p;
         var sub_key;
         var obj;
         if (branchFound == true){
          var p1 = "branch";
          obj1 = {};
          obj1[p1] = [cmdBranch[0].Branches]
          data.push(obj1)
         }       
         for (var i=0, iLen = cmdMain.length; i<iLen; i++) {
            p = cmdMain.ASGMT_Name
            obj = {};
            obj
 = [];
            sub_key = cmdMain.sub_key;
            for (var j=0, jLen=cmdSub.length; j<jLen; j++) {
              if (cmdSub.sub_key == sub_key) {
                 obj
.push(cmdSub.Long_Name);
              }
            }
            data.push(obj);
         }
         //set the graphic feature.attributes.Unit_Struc to our formatted cmdData String
         var cmdData = formatCmdData(data, featObjId, x, y);
         feature.attributes.graphicCmdData = cmdData;
   
         //this handles the display of the first facility record in the popup; feat.attributes.graphicCmdData handles the rest
         var tmpSpan = dojo.byId("graphic" + featObjId);
         if (tmpSpan != null){
          tmpSpan.innerHTML = cmdData;  
         };         
         
        });        
       }
       //since i'm a dumba** and can't figure out a single exit point for this function, we have to add the else clause below...
       else {
        p = "No Unit Data Available"
        obj = {}
        obj
 = []
        data.push(obj)
        //set the graphic feature.attributes.Unit_Strucure to our formatted cmdData String
        var cmdData = formatCmdData(data, featObjId, x, y);
        feature.attributes.graphicCmdData = cmdData;
        //this handles the display of the first facility record in the popup; feat.attributes.graphicCmdData handles the rest
        var tmpSpan = dojo.byId("graphic" + featObjId);
        if (tmpSpan != null){
         tmpSpan.innerHTML = cmdData;  
        };
       }
       //for some reason the cmd info div was still showing after infoWindow was cosed, this fixes that
       dojo.connect(map.infoWindow, "onHide", function() {dojo.destroy("obj" + featObjId);});
      })     
      
     })
      
     var template = new esri.dijit.PopupTemplate({
      title: "{site_code} - {facil_name}",
      description: tmpCont,
      mediaInfos: [{
       "title": "",
       "caption": "",
       "type": "image",
       "value": mediaInfoPhoto(feature.attributes,"Photo_URL")
      }]
     });
     feature.attributes.graphicCmdData = "Processing...";
     feature.setInfoTemplate(template);
     break;   
      
     }
     return feature;    
     
          });
        });
  
        // InfoWindow expects an array of features from each deferred
        // object that you pass. If the response from the task execution
        // above is not an array of features, then you need to add a callback
        // like the one above to post-process the response and return an
        // array of features.
  map.infoWindow.resize(265,300)
  map.infoWindow.setFeatures([ deferred ]);
        map.infoWindow.show(anchorPt);
  
    }

0 Kudos
0 Replies