Definition Query on Hosted Feature Service

3449
11
Jump to solution
10-11-2018 12:09 PM
DarlaPyron2
New Contributor

I'm working on an AGO map for our police department to use. They are inputting dates for vacation patrols and they are generally 1 to 7 days long. I have a def query on a hosted feature service to only display patrols for today, but I want them to stay on the map until the vacation is over. So this is the query on the HFS, and when you do the Query (POST) it will only select the relevant records. The problem neither I or anyone else here  knows how to get that query to save to the feature service because on the AGO map it is still showing all the dots. My workaround was to just run it as a feature service off the server with a similar def query, but I'd rather not be in sde. Thank you.

0 Kudos
11 Replies
MikeMinami
Esri Notable Contributor

I believe the issue is that your organization is not configured to use standard SQL queries. 

Go to the Organization tab, click the Security sub-tab and look for the checkbox that says:

Allow only standard SQL queries

I think this is probably unchecked. Esri recommends enabling it as described here:

Configure security settings—ArcGIS Online Help | ArcGIS 

Here's the specific section of the documentaiton

You may also see the following options if your organization was created prior to mid September 2018, and configured with these settings disabled. It is recommended that you enable these two security settings.

  • Allow access to the organization through HTTPS only—Check this box to ensure that your organization's data as well as any temporary identification tokens that allow access to your data are encrypted during communications over the Internet. Once enabled, check your organization to confirm that nothing is affected, such as your home page, maps, scenes, and apps. For example, you may need to update layers to use HTTPS in your maps and scenes.

  • Allow only standard SQL queries—Check this box to prevent nonstandard queries from being accepted in your organization's hosted feature layers. This helps prevent SQL injection attacks. All ArcGIS applications automatically support standard SQL queries. If your organization is currently using any third-party applications for querying data, confirm that they are using standard SQL syntax.

Sixty days after enabling these settings, the disable option will no longer be available on the Organization page.

Thanks,

Mike

DebbieBull
New Contributor II

Were you able to set a definition query for a Feature Layer View with a dynamic date function in the expression? I tried it with the following to filter records only for the last 20 days:

view_def = {'EndTime > CURRENT_TIMESTAMP - 20'}

and it raised a TypeError: 'is not JSON serializable"

0 Kudos