I'm using the ArcGIS API for JS to query a Feature Layer hosted on ArcGIS Server. I'm trying to include a variable name in my "where" statement. For example:
var params = new Query({
returnGeometry: true,
outFields: ["*"]
});
params.where = "PropOwner = 'City' AND Location = commName";
In the above, I'm querying buildings where the Property Owner field is populated with "City" and commName is a variable defined when a user selects a location from a drop down list. However, my query doesn't work when I pass it the variable commName.
I'm sure there is a simple way to do this. How do I need to revise my where statement to successfully pass it a variable name (in this case, commName)?
Solved! Go to Solution.
Thanks Robert, I was able to get it to work with a slight modification to your suggestion:
params.where = "PropOwner = 'City' AND Location = '" + commName + "'";
Paul,
Then the line would look like this:
params.where = "PropOwner = 'City' AND Location = " + commName;
Thanks Robert, I was able to get it to work with a slight modification to your suggestion:
params.where = "PropOwner = 'City' AND Location = '" + commName + "'";