Select to view content in your preferred language

Selected feature in dgrid not passing objectID to relationQuery

1434
19
Jump to solution
01-12-2018 08:33 AM
JayHill
Occasional Contributor II

I have a watchUtil for a popup opening, to trigger a related table query. Works perfectly when a user clicks on a feature on the map but when a grid row is clicked the relationshipQuery doesnt return any results.

                  watchUtils.when(app.view.popup, "selectedFeature", function photos(evt){
                       console.log(app.view.popup.selectedFeature);
                       query("#panelDetails").removeClass("in");

                       var objectID = app.view.popup.selectedFeature.attributes.OBJECTID;
console.log(objectID);
                       var queryTask = new QueryTask({
                            url: "https://services.arcgis.com/ZzrwjTRez6FJiOq4/arcgis/rest/services/Core_Locations_20171129/FeatureSer..."
                       });

                       relationQuery = new RelationshipQuery({
                            objectIds: [objectID],
                            outFields: ["Filename", "directory", "TYPE", "Usage", "Top_Depth", "Bottom_Depth"],
                            relationshipId: 1
                       });
console.log(relationQuery);
                       queryTask.executeRelationshipQuery(relationQuery).then(function(rslts){

                         document.getElementById("attDetails").innerHTML = "";
                         //No rslt given back here when clicking on dgrid
console.log(rslts);
                                       var features = rslts[objectID].features;
console.log(features);
0 Kudos
19 Replies
JayHill
Occasional Contributor II

It is the same up until console log on line 21. I get an empty array returned when the grid row is clicked. 

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Jay,

   Strange indeed. I normally see an issue where people are using the dgrid id field and it is returning as a string instead of a number and they don't realize that, but does not seem to be your case.

0 Kudos
JayHill
Occasional Contributor II

Ya stumped me. I figured it had something to do with the RelationshipQuery. 

0 Kudos
JayHill
Occasional Contributor II

can i email ya the live link?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Sure message it to me.

0 Kudos
JayHill
Occasional Contributor II

ha says i cant send ya a message

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

try again

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Jay,

  So this is what I am finding. Your Search widget is not returning the right features for the search. When I search for "#D-616 (STATE) LISBON" it returns 4 features and here are the objectids of those results (3048,3049,3050,3051).

When I click on the well with the actual name of "#D-616 (STATE) LISBON" its objectid is actually 2892. So the reason your images are not working for the dgrid click is the objectids in the results are not the correct ones. Now as to why the search is messing up so bad... I am not real sure. The one thing I see that is off is the JS is case sensitive and you have

searchFields: ["UWI","Well_Name", "Operator", "PROD_FORM", "Township", "Range"],

The "Operator" in the above list is not the correct field name it is "OPERATOR". See if that makes a difference.

0 Kudos
JayHill
Occasional Contributor II

Doh, my search sources was referencing old data still!  We had moved this project to AGOL over the holidays and the URL never got updated.  

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Great,

   Glad to help you figure this out.

Don't forget to mark this question as answered by clicking on the "Mark Correct" link on the reply that answered your question.

0 Kudos