<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Working with Related Records (query_relatedRecords) Python API in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/working-with-related-records-query-relatedrecords/m-p/789480#M1548</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I need to be able to summarize nested related records. I have been through the documentation and sample notebooks but have been unable to connect the dots on this. I would appreciate any help in understanding the process.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is where I am now:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;# get the feature layer collection from AGOL&lt;BR /&gt;feature_layer_collection = gis.content.get('bf7307237621413fb692f2f1a6f26211')&lt;BR /&gt;&lt;BR /&gt;# get the feature layer of interest&lt;BR /&gt;feature_layer = feature_layer_collection.layers[0]&lt;BR /&gt;&lt;BR /&gt;# get the related tables of interest&lt;BR /&gt;feature_table1 = feature_layer_collection.tables[0]&lt;BR /&gt;feature_table2 = feature_layer_collection.tables[1]&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;# query the related records from feature_table&lt;BR /&gt;&lt;BR /&gt;related_table1 = feature_layer.query_related_records(object_ids="2", relationship_id="1", out_fields="*")&lt;BR /&gt;related_table2 = feature_table1.query_related_records(object_ids='2', relationship_id="2", out_fields="*")&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;# Look at what's inside the result&lt;/P&gt;&lt;P&gt;related_table1?&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN class="" style="font-weight: bold;"&gt;Type:&lt;/SPAN&gt; dict &lt;SPAN class="" style="font-weight: bold;"&gt;String form:&lt;/SPAN&gt; {'fields': [{'name': 'objectid', 'type': 'esriFieldTypeOID',
&amp;nbsp;&amp;nbsp;&amp;nbsp; 'alias': 'ObjectID', 'sqlType': 'sql &amp;lt;...&amp;gt; 'sqlTypeOther',
 'length': 128, 'domain': None, 'defaultValue': None}], &lt;SPAN style="color: #ff6600;"&gt;&lt;STRONG&gt;'relatedRecordGroups': []&lt;/STRONG&gt;&lt;/SPAN&gt;} &lt;SPAN class="" style="font-weight: bold;"&gt;Length:&lt;/SPAN&gt; 2 &lt;SPAN class="" style="font-weight: bold;"&gt;Docstring:&lt;/SPAN&gt; &lt;SPAN style="color: #ff6600;"&gt;dict() -&amp;gt; new empty dictionary&lt;/SPAN&gt; dict(mapping) -&amp;gt; new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -&amp;gt; new dictionary initialized as if via: d = {} for k, v in iterable: d&lt;K&gt; = v dict(**kwargs) -&amp;gt; new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)&lt;/K&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;There is nothing in the 'relatedRecordsGroups', how do I access the values in the related table?&lt;/P&gt;&lt;P&gt;How do I summarize those values?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for any help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the URL for the feature service I am using in this example: &lt;A class="link-titled" href="https://services8.arcgis.com/ZbDl0kmn9FILhh7J/arcgis/rest/services/service_02ec21de18564c0782c96723d94a84ec/FeatureServer" title="https://services8.arcgis.com/ZbDl0kmn9FILhh7J/arcgis/rest/services/service_02ec21de18564c0782c96723d94a84ec/FeatureServer" rel="nofollow noopener noreferrer" target="_blank"&gt;https://services8.arcgis.com/ZbDl0kmn9FILhh7J/arcgis/rest/services/service_02ec21de18564c0782c96723d94a84ec/FeatureServe…&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 16:55:00 GMT</pubDate>
    <dc:creator>BenjaminSperry1</dc:creator>
    <dc:date>2021-12-12T16:55:00Z</dc:date>
    <item>
      <title>Working with Related Records (query_relatedRecords) Python API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/working-with-related-records-query-relatedrecords/m-p/789480#M1548</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I need to be able to summarize nested related records. I have been through the documentation and sample notebooks but have been unable to connect the dots on this. I would appreciate any help in understanding the process.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is where I am now:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;# get the feature layer collection from AGOL&lt;BR /&gt;feature_layer_collection = gis.content.get('bf7307237621413fb692f2f1a6f26211')&lt;BR /&gt;&lt;BR /&gt;# get the feature layer of interest&lt;BR /&gt;feature_layer = feature_layer_collection.layers[0]&lt;BR /&gt;&lt;BR /&gt;# get the related tables of interest&lt;BR /&gt;feature_table1 = feature_layer_collection.tables[0]&lt;BR /&gt;feature_table2 = feature_layer_collection.tables[1]&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;# query the related records from feature_table&lt;BR /&gt;&lt;BR /&gt;related_table1 = feature_layer.query_related_records(object_ids="2", relationship_id="1", out_fields="*")&lt;BR /&gt;related_table2 = feature_table1.query_related_records(object_ids='2', relationship_id="2", out_fields="*")&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;# Look at what's inside the result&lt;/P&gt;&lt;P&gt;related_table1?&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN class="" style="font-weight: bold;"&gt;Type:&lt;/SPAN&gt; dict &lt;SPAN class="" style="font-weight: bold;"&gt;String form:&lt;/SPAN&gt; {'fields': [{'name': 'objectid', 'type': 'esriFieldTypeOID',
&amp;nbsp;&amp;nbsp;&amp;nbsp; 'alias': 'ObjectID', 'sqlType': 'sql &amp;lt;...&amp;gt; 'sqlTypeOther',
 'length': 128, 'domain': None, 'defaultValue': None}], &lt;SPAN style="color: #ff6600;"&gt;&lt;STRONG&gt;'relatedRecordGroups': []&lt;/STRONG&gt;&lt;/SPAN&gt;} &lt;SPAN class="" style="font-weight: bold;"&gt;Length:&lt;/SPAN&gt; 2 &lt;SPAN class="" style="font-weight: bold;"&gt;Docstring:&lt;/SPAN&gt; &lt;SPAN style="color: #ff6600;"&gt;dict() -&amp;gt; new empty dictionary&lt;/SPAN&gt; dict(mapping) -&amp;gt; new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -&amp;gt; new dictionary initialized as if via: d = {} for k, v in iterable: d&lt;K&gt; = v dict(**kwargs) -&amp;gt; new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)&lt;/K&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;There is nothing in the 'relatedRecordsGroups', how do I access the values in the related table?&lt;/P&gt;&lt;P&gt;How do I summarize those values?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for any help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the URL for the feature service I am using in this example: &lt;A class="link-titled" href="https://services8.arcgis.com/ZbDl0kmn9FILhh7J/arcgis/rest/services/service_02ec21de18564c0782c96723d94a84ec/FeatureServer" title="https://services8.arcgis.com/ZbDl0kmn9FILhh7J/arcgis/rest/services/service_02ec21de18564c0782c96723d94a84ec/FeatureServer" rel="nofollow noopener noreferrer" target="_blank"&gt;https://services8.arcgis.com/ZbDl0kmn9FILhh7J/arcgis/rest/services/service_02ec21de18564c0782c96723d94a84ec/FeatureServe…&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:55:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/working-with-related-records-query-relatedrecords/m-p/789480#M1548</guid>
      <dc:creator>BenjaminSperry1</dc:creator>
      <dc:date>2021-12-12T16:55:00Z</dc:date>
    </item>
    <item>
      <title>Re: Working with Related Records (query_relatedRecords) Python API</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/working-with-related-records-query-relatedrecords/m-p/789481#M1549</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Crickets for a year and a half... Anyone at Esri monitoring?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to figure out how to create the relationships in the first place. Is this done in Pro and published to AGOL? Or is this the "Join Features" option in AGOL's analysis tools?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Apr 2020 18:43:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/working-with-related-records-query-relatedrecords/m-p/789481#M1549</guid>
      <dc:creator>davedoesgis</dc:creator>
      <dc:date>2020-04-09T18:43:39Z</dc:date>
    </item>
  </channel>
</rss>

