<?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 Re: Iterate Over ArcGIS Online Table using Javascript in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/iterate-over-arcgis-online-table-using-javascript/m-p/1066953#M73458</link>
    <description>&lt;P&gt;It's just like querying a feature layer. You &lt;A href="https://doc.arcgis.com/en/arcgis-online/share-maps/link-to-items.htm" target="_self"&gt;can get the url&lt;/A&gt; for the table item in ArcGIS Online, plug it into a &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-QueryTask.html" target="_self"&gt;QueryTask&lt;/A&gt;, execute the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html" target="_self"&gt;Query&lt;/A&gt;, then iterate over the results. Here's an example:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var qTask = new QueryTask({
  url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/SpatioTemporalAggregation/RainfallTimeSeriesDataIllinois/MapServer/8"
});

// Set the query parameters with a where clause and to return all fields.
var params = new Query({
  returnGeometry: false,
  where: "avg_monthly_rainfall &amp;gt; 100",
  outFields: ["*"]
});

// executes the query and handle the resulting FeatureSet.
qTask.execute(params)
.then(function(featureSet) {
  featureSet.features.forEach(function(feature) {
    console.log(feature);
    for (const [fieldName, fieldValue] of Object.entries(feature.attributes)) {
      // Do something with the field names and field values.
      console.log(`\t${fieldName}: ${fieldValue}`);
    }
  });
})
.catch(function (error) {
  console.error("Promise rejected: ", error.message);
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 10 Jun 2021 15:50:45 GMT</pubDate>
    <dc:creator>BlakeTerhune</dc:creator>
    <dc:date>2021-06-10T15:50:45Z</dc:date>
    <item>
      <title>Iterate Over ArcGIS Online Table using Javascript</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/iterate-over-arcgis-online-table-using-javascript/m-p/1066700#M73446</link>
      <description>&lt;P&gt;I am trying to learn how to iterate over a table stored as a feature service in my ArcGIS Online Content. I am just getting started with the Javascript API for ArcGIS so my knowledge isn't top level yet.&lt;/P&gt;&lt;P&gt;What I am trying to do it dynamically update a URL using values from 2 columns in the table. I want to iterate through each row and grab the value from the 2 columns and inject them into a URL via concatenation.&lt;/P&gt;&lt;P&gt;Drawing from my python background, it would be something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;URL = www.mywebsite.com

for row in cursor:
    URL + "\" + row[1] + "some_other_URL_string_stuff" + row[2]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think what I need to do is use the following code to do so, but&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;I am not sure how to reference the table in the script. I've tried setting the element ID to the GUID of the feature table but that doesn't seem to work. I've also tried the name. I've combed through the Javascript help docs, but they are difficult to navigate and I can't seem to find examples of what I am trying to do.&lt;/LI&gt;&lt;LI&gt;I don't really know how to concatenate the values from the columns in the table using javascript.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var table = document.getElementById("mytab1");
for (var i = 0, row; row = table.rows[i]; i++) {
   //iterate through rows
   //rows would be accessed using the "row" variable assigned in the for loop
   for (var j = 0, col; col = row.cells[j]; j++) {
     //iterate through columns
     //columns would be accessed using the "col" variable assigned in the for loop
   }  
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jun 2021 23:27:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/iterate-over-arcgis-online-table-using-javascript/m-p/1066700#M73446</guid>
      <dc:creator>MikeMacRae</dc:creator>
      <dc:date>2021-06-09T23:27:32Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate Over ArcGIS Online Table using Javascript</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/iterate-over-arcgis-online-table-using-javascript/m-p/1066953#M73458</link>
      <description>&lt;P&gt;It's just like querying a feature layer. You &lt;A href="https://doc.arcgis.com/en/arcgis-online/share-maps/link-to-items.htm" target="_self"&gt;can get the url&lt;/A&gt; for the table item in ArcGIS Online, plug it into a &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-QueryTask.html" target="_self"&gt;QueryTask&lt;/A&gt;, execute the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-support-Query.html" target="_self"&gt;Query&lt;/A&gt;, then iterate over the results. Here's an example:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var qTask = new QueryTask({
  url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/SpatioTemporalAggregation/RainfallTimeSeriesDataIllinois/MapServer/8"
});

// Set the query parameters with a where clause and to return all fields.
var params = new Query({
  returnGeometry: false,
  where: "avg_monthly_rainfall &amp;gt; 100",
  outFields: ["*"]
});

// executes the query and handle the resulting FeatureSet.
qTask.execute(params)
.then(function(featureSet) {
  featureSet.features.forEach(function(feature) {
    console.log(feature);
    for (const [fieldName, fieldValue] of Object.entries(feature.attributes)) {
      // Do something with the field names and field values.
      console.log(`\t${fieldName}: ${fieldValue}`);
    }
  });
})
.catch(function (error) {
  console.error("Promise rejected: ", error.message);
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jun 2021 15:50:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/iterate-over-arcgis-online-table-using-javascript/m-p/1066953#M73458</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-06-10T15:50:45Z</dc:date>
    </item>
  </channel>
</rss>

