<?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: Changing where clause for createQuery() in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/changing-where-clause-for-createquery/m-p/1317040#M81914</link>
    <description>&lt;P&gt;You should put this in a separate question. And it's quite an ask to review this much coding. It's better to create a small example that illustrates the problem&lt;/P&gt;</description>
    <pubDate>Wed, 09 Aug 2023 17:50:59 GMT</pubDate>
    <dc:creator>KenBuja</dc:creator>
    <dc:date>2023-08-09T17:50:59Z</dc:date>
    <item>
      <title>Changing where clause for createQuery()</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/changing-where-clause-for-createquery/m-p/1316724#M81891</link>
      <description>&lt;P&gt;Hi everyone, I'm trying to download statistics for a drawn buffer. I'm able to do that but if I change my year (the where clause) instead of downloading the data for the new year, it keeps using the same year. For instance, if I select 2020, it will download the data statistics using 2020 year but then if I switch to the 2021 year it still downloads 2020.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;let querycentroids = layer.createQuery();
querycentroids.spatialRelationship = "contains";
querycentroids.geometry = buffgra.geometry;
$(".chosen-benchmark")
    .chosen()
    .change(function () {
      var option = [$("#YearSource").val()];
      var result = "'" + option.join("','") + "'";
      querycentroids.where="year IN (" + result + ")"
      if ($(".chosen-benchmark").val() == 'Toronto') {
        console.log('Toronto')
        if ($(".chosen-year").val() == '2020') {
          console.log('works')
          document.getElementById("report").onclick = () =&amp;gt; {
          downloadData(Toronto_2020,option)

          }
        }
        else if ($(".chosen-year").val() == '2021') {
          console.log('works2021')          
          document.getElementById("report").onclick = () =&amp;gt; {
          downloadData(Toronto_2021,option)

          }
        }
        else if ($(".chosen-year").val() == '2022') {
          console.log('works2022')          
          document.getElementById("report").onclick = () =&amp;gt; {
          downloadData(Toronto_2022,option)

          }
        }
        $(".chosen-year")
        .chosen()
        .change(function () {
          var yearoptions2 = [$("#YearSource").val()];
          var yearresult2 = "'" + yearoptions2.join("','") + "'";
          querycentroids.where="year IN (" + yearresult2 + ")"

          if ($(".chosen-year").val() == '2020') {
            console.log('2020')
            document.getElementById("report").onclick = () =&amp;gt; {
              downloadData(Toronto_2020,yearoptions2)

            }
          }
          else if ($(".chosen-year").val() == '2021') {
            console.log('2021')
            document.getElementById("report").onclick = () =&amp;gt; {
              downloadData(Toronto_2021,yearoptions2)

            }
          }
          else if ($(".chosen-year").val() == '2022') {
            console.log('2022')
            document.getElementById("report").onclick = () =&amp;gt; {
              downloadData(Toronto_2022,yearoptions2)

            }
          }
        })
      }
      else if ($(".chosen-benchmark").val() == 'BC') {
        //// same stuff

      }
    });

  });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/53756"&gt;@UndralBatsukh&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/6522"&gt;@JoelBennett&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2839"&gt;@KenBuja&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 12:02:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/changing-where-clause-for-createquery/m-p/1316724#M81891</guid>
      <dc:creator>Charan</dc:creator>
      <dc:date>2023-08-09T12:02:49Z</dc:date>
    </item>
    <item>
      <title>Re: Changing where clause for createQuery()</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/changing-where-clause-for-createquery/m-p/1316860#M81899</link>
      <description>&lt;P&gt;Are you checking your console to see if the if statements in line 12, 19, 26, 40, 47, or 54 are being evaluated properly? Is the field you're querying a text field or a numeric field? Should the query be "year in (2021, 2022)" or "year in ('2021', '2022')"?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 13:55:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/changing-where-clause-for-createquery/m-p/1316860#M81899</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2023-08-09T13:55:02Z</dc:date>
    </item>
    <item>
      <title>Re: Changing where clause for createQuery()</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/changing-where-clause-for-createquery/m-p/1316867#M81900</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2839"&gt;@KenBuja&lt;/a&gt;&amp;nbsp;my console.log() for the above lines is working correctly, when I select the year 2020 and then select Toronto, it prints Toronto and works (lines 11 and 13). and when I switch to 2021 it prints 2021(line 48). The year field is numeric. For queries, it should only take one value at a time, so if I do 2020 it should be year = 2020, but if I switch my select option to 2021 it should be year=2021&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 14:12:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/changing-where-clause-for-createquery/m-p/1316867#M81900</guid>
      <dc:creator>Charan</dc:creator>
      <dc:date>2023-08-09T14:12:04Z</dc:date>
    </item>
    <item>
      <title>Re: Changing where clause for createQuery()</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/changing-where-clause-for-createquery/m-p/1316872#M81901</link>
      <description>&lt;P&gt;Is there a way to rest queries, because the if statement seems to be working but the .where= doesn't seem to reset&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 14:23:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/changing-where-clause-for-createquery/m-p/1316872#M81901</guid>
      <dc:creator>Charan</dc:creator>
      <dc:date>2023-08-09T14:23:38Z</dc:date>
    </item>
    <item>
      <title>Re: Changing where clause for createQuery()</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/changing-where-clause-for-createquery/m-p/1316878#M81904</link>
      <description>&lt;P&gt;You're adding quotes to the where clause, which is causing the problem. The method val is probably also returning a string, so I'm converting it to an integer, also.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var option = ParseInt([$("#YearSource").val()]);
//var result = "'" + option.join("','") + "'";
querycentroids.where="year = " + option; &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 14:33:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/changing-where-clause-for-createquery/m-p/1316878#M81904</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2023-08-09T14:33:05Z</dc:date>
    </item>
    <item>
      <title>Re: Changing where clause for createQuery()</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/changing-where-clause-for-createquery/m-p/1316882#M81905</link>
      <description>&lt;P&gt;I changed my code using this but my query is not resetting. Please see the &lt;A href="https://codepen.io/Charanb98/pen/wvYdQYV" target="_self"&gt;code&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 14:48:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/changing-where-clause-for-createquery/m-p/1316882#M81905</guid>
      <dc:creator>Charan</dc:creator>
      <dc:date>2023-08-09T14:48:23Z</dc:date>
    </item>
    <item>
      <title>Re: Changing where clause for createQuery()</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/changing-where-clause-for-createquery/m-p/1316893#M81906</link>
      <description>&lt;P&gt;I had a small mistake in the code. It should be "parseInt".&lt;/P&gt;&lt;P&gt;When you run the query after changing the year, have you checked the where clause to make sure it's correct?&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 14:52:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/changing-where-clause-for-createquery/m-p/1316893#M81906</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2023-08-09T14:52:01Z</dc:date>
    </item>
    <item>
      <title>Re: Changing where clause for createQuery()</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/changing-where-clause-for-createquery/m-p/1316895#M81907</link>
      <description>&lt;P&gt;yup I fixed the parseInt, and when I switch to the year, I checked the console and I see where the clause becomes where: "year = 2021".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 15:38:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/changing-where-clause-for-createquery/m-p/1316895#M81907</guid>
      <dc:creator>Charan</dc:creator>
      <dc:date>2023-08-09T15:38:38Z</dc:date>
    </item>
    <item>
      <title>Re: Changing where clause for createQuery()</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/changing-where-clause-for-createquery/m-p/1316908#M81908</link>
      <description>&lt;P&gt;From what I can tell in the code (I can't run it due to a permissions problem), it looks like you're running the querycentroids query before you reset the year. Where is the query run again after you change the where clause?&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 15:14:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/changing-where-clause-for-createquery/m-p/1316908#M81908</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2023-08-09T15:14:29Z</dc:date>
    </item>
    <item>
      <title>Re: Changing where clause for createQuery()</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/changing-where-clause-for-createquery/m-p/1316929#M81909</link>
      <description>&lt;P&gt;Im able to download the correct data now, the only problem is if i draw multiple buffers on the map it will only give the data for the first drawn buffer, please see the updated code:&amp;nbsp;&lt;A href="https://codepen.io/Charanb98/pen/wvYdQYV" target="_blank"&gt;https://codepen.io/Charanb98/pen/wvYdQYV&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 15:42:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/changing-where-clause-for-createquery/m-p/1316929#M81909</guid>
      <dc:creator>Charan</dc:creator>
      <dc:date>2023-08-09T15:42:18Z</dc:date>
    </item>
    <item>
      <title>Re: Changing where clause for createQuery()</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/changing-where-clause-for-createquery/m-p/1317040#M81914</link>
      <description>&lt;P&gt;You should put this in a separate question. And it's quite an ask to review this much coding. It's better to create a small example that illustrates the problem&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 17:50:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/changing-where-clause-for-createquery/m-p/1317040#M81914</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2023-08-09T17:50:59Z</dc:date>
    </item>
    <item>
      <title>Re: Changing where clause for createQuery()</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/changing-where-clause-for-createquery/m-p/1317131#M81927</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2839"&gt;@KenBuja&lt;/a&gt;&amp;nbsp;I had created a new question, could you please check it out&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2023 15:41:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/changing-where-clause-for-createquery/m-p/1317131#M81927</guid>
      <dc:creator>Charan</dc:creator>
      <dc:date>2023-08-10T15:41:17Z</dc:date>
    </item>
  </channel>
</rss>

