Using this example: https://community.esri.com/t5/arcgis-api-for-javascript/passing-url-parameters-to-query-feature-layers/td-p/284882
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.
For example, in the console log I have the expr variable being written out and that reads:
Q_NAME = 'Baby's breath'
and in my ArcGIS Server Manager I am receiving the following error message:
An invalid where clause or definition expression has been requested: "Q_NAME = 'Baby's breath'"
but when I change the expression to:
var expr = 'Q_NAME = "' + species + '"';
If receive the following error message:
Geodatabase error: Underlying DBMS error [GIS.Layer][STATE_ID = 0].
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.