I have a feature layer that I'm trying to pass a definition to and getting goofy results.
My setup is a dojo select which passes a "TYPE" of facility and three Dojo radio buttons for Showing all data for that TYPE and/or all data for that type that is Verified Y/N.
If I pick all, it just shows the data for that facility type. This works.
If I pick No verified, it shows all data for that facility type and where the Verified field says 'N', this works.
If I pick Yes verified, it shows all data for that facility type and where the Verified field says 'Y', this does NOT work, This tends to show all facility types where Verified equals 'Y', ignoring my Type requirement.
I'm able to hit the REST service manually and "TYPE='ambulance' and VERIFIED='Y'" works. So it's not the service.
I've set alerts and console logs, the correct values are being passed to this switch statement, it seems thesetDefinitionExpression for "Y" is the failure point.
switch(check){ // Radio buttons set value for check,
case "N":
operationsPointLayer.setDefinitionExpression(("TYPE='"+ value +"'") && ("VERIFIED='N'"));
break;
case "Y":
console.log(value +" -- "+check); //ambulance -- Y //TYPE='ambulance' and VERIFIED='Y' operationsPointLayer.setDefinitionExpression(("TYPE='"+ value +"'") && ("VERIFIED='Y'"));
break; case "z":
operationsPointLayer.setDefinitionExpression("TYPE='"+ value +"'");
break;
}
I've attached the complete page if needed.
I've even taken the line where VERIFIED='N' which works and tried VERIFIED != 'N' which didn't work.
I'm stumped any ideas would be appreciated.
Solved! Go to Solution.
Bill,
Not exactly. The issue is your SQL Syntax. Your code should look like:
operationsPointLayer.setDefinitionExpression("TYPE='"+ value +"' AND VERIFIED='Y'");
After playing with this for a while, I realized I may have found a bug or limitation:
operationsPointLayer.setDefinitionExpression(("TYPE='"+ value +"'") && ("VERIFIED='Y'"));
Gives me all facility types Verified Y, basically ignores first expression
operationsPointLayer.setDefinitionExpression(( ("VERIFIED='Y'")&&("TYPE='"+ value +"'"));
Gives me the selected facility type ignoring the Verified field.(first expression)
So ( condition A and condition B) is not the same end result as (condition B and condition A)
FeatureLayer.setDefinitionExpression() may only work with a simple expression.
The rest service for the feature layer can handle the dual field request, so it's in the api.
Off to a support case.
Bill,
Not exactly. The issue is your SQL Syntax. Your code should look like:
operationsPointLayer.setDefinitionExpression("TYPE='"+ value +"' AND VERIFIED='Y'");
Thank you, faster than Esri tech Support, although they did call back after your e-mail.
I did earlier try to replace && with AND but it was outside the quotes and not seen as part of the string.
Thanks….