Hi All:
I want to be able to programmaticaly apply a "<>" operator to a definition expression. Nothing complicated, just something like layer.definitionExpression = "Status <> 'Closed'" because I don't want to include an OR clause in the query.
The error that I get is "'where' parameter is invalid" however if I try to apply the same query to the REST endpoint it returns the data fine. I tried encoding the string manually and also using encodeURIComponent, but neither worked.
Anyone have any idea what I am doing wrong?
Best,
MTC
Solved! Go to Solution.
Yeah, that's definitely incorrect. I should have tested it first. However, using "<>" in a definitionExpression works when added to this sample.
const featureLayer = new FeatureLayer({
url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/Landscape_Trees/FeatureServer/0"
});
map.add(featureLayer);
featureLayer.definitionExpression = "Cmn_Name <> 'White oak'";
Can you provide more code to replicate the problem?
Use "!=" instead of "<>"
Unfortunately, I tried that too. No avail.
Yeah, that's definitely incorrect. I should have tested it first. However, using "<>" in a definitionExpression works when added to this sample.
const featureLayer = new FeatureLayer({
url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/Landscape_Trees/FeatureServer/0"
});
map.add(featureLayer);
featureLayer.definitionExpression = "Cmn_Name <> 'White oak'";
Can you provide more code to replicate the problem?
It's funny how a simple question can shake something important loose:
this.apply = function () {
console.log(self.queryEditor.innerHTML); // prints "Status <> 'Open'"
featureLayer.definitionExpression = self.queryEditor.innerHTML;
featureTable.refresh();
};
Now obviously, changing that from innerHTML to innerText yields:
this.apply = function () {
console.log(self.queryEditor.innerText); // prints "Status <> 'Open'"
featureLayer.definitionExpression = self.queryEditor.innerText;
featureTable.refresh();
};
And this works as expected.
Thanks for the nudge.