<?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: JS API Query URL Parameters unable to handle apostrophes in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/js-api-query-url-parameters-unable-to-handle/m-p/1027625#M71795</link>
    <description>&lt;P&gt;In a query, 'string' is a string, but "string" is a &lt;EM&gt;column&lt;/EM&gt; named string. For that reason, single and double-quotes are &lt;STRONG&gt;not&lt;/STRONG&gt; interchangeable when constructing a query statement.&lt;/P&gt;&lt;P&gt;To escape a single quote in SQL, you simply give it &lt;EM&gt;twice, &lt;/EM&gt;i.e., &lt;FONT face="courier new,courier"&gt;'Baby''s breath'&lt;/FONT&gt;. That's &lt;U&gt;two single-quote&lt;/U&gt; characters, not a double-quote. I put it in monospace font to make it clearer.&lt;/P&gt;&lt;P&gt;Which poses a problem when the table stores it with one, but a simple replace of &lt;FONT face="courier new,courier"&gt;' → ''&lt;/FONT&gt; should do the trick.&lt;/P&gt;&lt;P&gt;To demonstrate that the query functions properly with two single-quotes, &lt;A href="https://maps.co.kendall.il.us/server/rest/services/Hosted/Current_Cadastral_Features/FeatureServer/1/query?where=owner_name+like+%27%25%27%27%25%27&amp;amp;outFields=owner_name&amp;amp;returnGeometry=false&amp;amp;f=pjson" target="_self"&gt;here's a query of my county's parcels&lt;/A&gt;, with the query statement &lt;STRONG&gt;owner_name like '%''%'&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;You'll see that the query successfully evaluates and returns all parcels with a single-quote somewhere in the name.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
 "exceededTransferLimit": false,
 "features": [
  {
   "attributes": {
    "owner_name": "PATRICK J &amp;amp; NANCY M O'CONNELL"
   }
  },
  {
   "attributes": {
    "owner_name": "RANDALL ROBINSON OBRA '93 TRUST NORTHERN TRUST CO GRDN &amp;amp; TR"
   }
  },
...
]}&lt;/LI-CODE&gt;</description>
    <pubDate>Wed, 17 Feb 2021 15:57:13 GMT</pubDate>
    <dc:creator>jcarlson</dc:creator>
    <dc:date>2021-02-17T15:57:13Z</dc:date>
    <item>
      <title>JS API Query URL Parameters unable to handle apostrophes</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/js-api-query-url-parameters-unable-to-handle/m-p/1027619#M71794</link>
      <description>&lt;P&gt;Using this example:&amp;nbsp;&lt;A href="https://community.esri.com/t5/arcgis-api-for-javascript/passing-url-parameters-to-query-feature-layers/td-p/284882" target="_blank" rel="noopener"&gt;https://community.esri.com/t5/arcgis-api-for-javascript/passing-url-parameters-to-query-feature-layers/td-p/284882&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I pass the species name via the parameter 'cname' (ie: cname=Alewife) It seems to work just fine with names that have parentheses (cname=Phragmites+%28Invasive%29) and dashes (cname=Woodland+forget-me-not) but it doesn't seem to query correctly when an apostrophe appear in the name. I've tried a few different string replaces, splitting etc but nothing seems to be working.&lt;/P&gt;&lt;P&gt;For example, in the console log I have the expr variable being written out and that reads:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Q_NAME = 'Baby's breath'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and in my ArcGIS Server Manager I am receiving the following error message:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;An invalid where clause or definition expression has been requested: "Q_NAME = 'Baby's breath'"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;but when I change the expression to:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var expr = 'Q_NAME  = "' + species + '"';&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If receive the following error message:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Geodatabase error: Underlying DBMS error [GIS.Layer][STATE_ID = 0].&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't quite know what I am doing wrong as the species variable is printing out correctly in the console.log but is not querying the feature layer correctly.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2021 15:41:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/js-api-query-url-parameters-unable-to-handle/m-p/1027619#M71794</guid>
      <dc:creator>luckachi</dc:creator>
      <dc:date>2021-02-17T15:41:17Z</dc:date>
    </item>
    <item>
      <title>Re: JS API Query URL Parameters unable to handle apostrophes</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/js-api-query-url-parameters-unable-to-handle/m-p/1027625#M71795</link>
      <description>&lt;P&gt;In a query, 'string' is a string, but "string" is a &lt;EM&gt;column&lt;/EM&gt; named string. For that reason, single and double-quotes are &lt;STRONG&gt;not&lt;/STRONG&gt; interchangeable when constructing a query statement.&lt;/P&gt;&lt;P&gt;To escape a single quote in SQL, you simply give it &lt;EM&gt;twice, &lt;/EM&gt;i.e., &lt;FONT face="courier new,courier"&gt;'Baby''s breath'&lt;/FONT&gt;. That's &lt;U&gt;two single-quote&lt;/U&gt; characters, not a double-quote. I put it in monospace font to make it clearer.&lt;/P&gt;&lt;P&gt;Which poses a problem when the table stores it with one, but a simple replace of &lt;FONT face="courier new,courier"&gt;' → ''&lt;/FONT&gt; should do the trick.&lt;/P&gt;&lt;P&gt;To demonstrate that the query functions properly with two single-quotes, &lt;A href="https://maps.co.kendall.il.us/server/rest/services/Hosted/Current_Cadastral_Features/FeatureServer/1/query?where=owner_name+like+%27%25%27%27%25%27&amp;amp;outFields=owner_name&amp;amp;returnGeometry=false&amp;amp;f=pjson" target="_self"&gt;here's a query of my county's parcels&lt;/A&gt;, with the query statement &lt;STRONG&gt;owner_name like '%''%'&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;You'll see that the query successfully evaluates and returns all parcels with a single-quote somewhere in the name.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
 "exceededTransferLimit": false,
 "features": [
  {
   "attributes": {
    "owner_name": "PATRICK J &amp;amp; NANCY M O'CONNELL"
   }
  },
  {
   "attributes": {
    "owner_name": "RANDALL ROBINSON OBRA '93 TRUST NORTHERN TRUST CO GRDN &amp;amp; TR"
   }
  },
...
]}&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 17 Feb 2021 15:57:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/js-api-query-url-parameters-unable-to-handle/m-p/1027625#M71795</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-02-17T15:57:13Z</dc:date>
    </item>
    <item>
      <title>Re: JS API Query URL Parameters unable to handle apostrophes</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/js-api-query-url-parameters-unable-to-handle/m-p/1027631#M71796</link>
      <description>&lt;P&gt;You are awesome&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;&amp;nbsp; - thank you!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Feb 2021 16:23:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/js-api-query-url-parameters-unable-to-handle/m-p/1027631#M71796</guid>
      <dc:creator>luckachi</dc:creator>
      <dc:date>2021-02-18T16:23:32Z</dc:date>
    </item>
    <item>
      <title>Re: JS API Query URL Parameters unable to handle apostrophes</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/js-api-query-url-parameters-unable-to-handle/m-p/1027664#M71798</link>
      <description>&lt;P&gt;This is some really good information!&amp;nbsp; I am surprised this has not tripped me up too.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2021 16:36:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/js-api-query-url-parameters-unable-to-handle/m-p/1027664#M71798</guid>
      <dc:creator>MatthewDriscoll</dc:creator>
      <dc:date>2021-02-17T16:36:50Z</dc:date>
    </item>
  </channel>
</rss>

