thebillcarr

Display related table info

Discussion created by thebillcarr on Apr 7, 2014
Latest reply on Apr 17, 2014 by MKostuk-esristaff
Greetings,

I'm attempting to view related tables from a query in either a info window, popup or attribute inspector. I have the relate set up and I can see the related table info in the dev. console, but I'm new to this (and clueless to boot).


 dojo.connect(map,"onClick",function(evt){
          var query = new esri.tasks.Query();
          query.geometry = pointToExtent(map,evt.mapPoint,10);
          var deferred = featureLayer.selectFeatures(query,esri.layers.FeatureLayer.SELECTION_NEW);
          
          deferred(function (results) {       
           dojo.forEach(results, function(res){
            var relatedTopsQuery = new esri.tasks.RelationshipQuery();
            relatedTopsQuery.outFields = ["*"];
            relatedTopsQuery.relationshipId = 0;
            relatedTopsQuery.objectIds = [res.attributes['OBJECTID']];
            infoTemplate:template;
            
            
            mydeferred = featureLayer.queryRelatedFeatures(relatedTopsQuery, function(relatedRecords) {
             console.log("Related records: ", relatedRecords);
             
             var relationships = featureLayer.relationships;
             
dojo.forEach(relationships,function(relationship){
  console.log("name: " + relationship.name);
  console.log("id: " + relationship.id);
  console.log("relationship id: "   + relationship.relatedTableId);
  
});
             
             
             
             
             
             
              var fset = relatedRecords[res.attributes['OBJECTID']]; 
              var featureArray = [];
              
              dojo.forEach(fset.features, function(feature){
               featureArray.push(feature);              
              
              
              });
                          
             //map.infoWindow.setFeatures([relatedRecords.features]);
             map.infoWindow.setFeatures(relatedRecords.features);
             map.infoWindow.show(evt.mapPoint); 
             
              
            }); 
            
            // Add dojo.Deferred instead of relatedRecords or fset
            map.infoWindow.setFeatures([mydeferred]);
            map.infoWindow.show(evt.mapPoint);    
                     


I took this from a sample on fiddle, and I'm pretty sure I've done something wrong. Any ideas? Wisdom? Logic?

Outcomes