QueryTask on REST Endpoint that ends in /queryRelatedRecords

3018
3
Jump to solution
06-23-2015 12:54 PM
KeithAnderson
New Contributor III

Folks

Is this expected to work?

I cannot get it to go.

I am guessing I have to create a new RelationQuery through code.

Let me know.

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <!--The viewport meta tag is used to improve the presentation and behavior of the samples
      on iOS devices-->
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
    <title>Query State Info without Map</title>


    <script src="http://js.arcgis.com/3.13/"></script>
    <script>
        require([
          "dojo/dom", "dojo/on",
          "esri/tasks/query", "esri/tasks/QueryTask", "dojo/domReady!"
        ], function (dom, on, Query, QueryTask ) {


            var queryTask = new QueryTask("http://localhost:6080/arcgis/rest/services/Ggov/MI_Default/MapServer/7/queryRelatedRecords");


            var query = new Query();
            query.returnGeometry = false;
            query.outFields = ["*"];
            query.relationshipId = 0;
            query.objectIds = [2, 3];


            queryTask.execute(query, showResults);




            function showResults(results) {
                var resultItems = [];
                var resultCount = results.features.length;
                for (var i = 0; i < resultCount; i++) {
                    var featureAttributes = results.features.attributes;
                    for (var attr in featureAttributes) {
                        resultItems.push("<b>" + attr + ":</b>  " + featureAttributes[attr] + "<br>");
                    }
                    resultItems.push("<br>");
                }
                dom.byId("info").innerHTML = resultItems.join("");
            }
        });
    </script>
</head>


<body>
    <div id="info" style="padding:5px; margin:5px; background-color:#eee;">
    </div>
</body>
</html>

Thanks

Keith Anderson

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Keith,

   You need to use the RelationshipQuery class and the QueryTasks executeRelationshipQuery method.

View solution in original post

0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Emeritus

Keith,

   You need to use the RelationshipQuery class and the QueryTasks executeRelationshipQuery method.

0 Kudos
KeithAnderson
New Contributor III

Thanks Robert...Thats what I am working on now..

0 Kudos
KeithAnderson
New Contributor III

I take that back... I am using .queryRelatedFeatures.

I will check into .executeRelationshipQuery too.

Thanks Robert

0 Kudos