How to use the Update Definition operation on a hosted layer view in AGOL

2975
11
Jump to solution
05-17-2018 12:11 PM
Trippetoe
Occasional Contributor III

I am trying to use the Update Definition operation on a hosted feature layer view through the Admin view of the REST endpoint of the feature service.  The change i am trying to make is setting some default values in the 'templates' element.  However, regardless of the changes i try to make to the definition, i am getting the following error message:

Invalid definition for 'DefinitionQuery'.
Invalid definition for System.String

Even for the simplest change of setting "lastEditDate" : " ", I get the error message.  I am the owner of the view.

The definition query (as generated by AGOL when creating the view) looks like this:

{

...

"viewDefinitionQuery" : "(IsActive = 'Yes') AND (CaseType = 'Report') AND (ReportStatus = 'Received')",
"definitionQuery" : "(IsActive = 'Yes') AND (CaseType = 'Report') AND (ReportStatus = 'Received')"

...

}

Any thoughts on what's going on?

1 Solution

Accepted Solutions
JohnMarino
New Contributor III

The issue appears to be with having a Definition Query applied to the Feature Layer View when attempting to update its 'definition.'

In case anyone else encounters this error message, here is a workaround that was successful for me:

  1. remove all definition queries for the feature layer view [edit: be sure to save your definition queries for later retrieval, or at least remember what they are]
  2. update the definition of the feature layer view
  3. re-enable any definition queries previously removed in step 1

View solution in original post

11 Replies
Trippetoe
Occasional Contributor III

Esri Tech Support has verified that this is a bug in AGOL.  The bug number is #BUG-000114175

0 Kudos
larrycamp
New Contributor III

Is the bug the whole method of using Update Layer Definition?

Or is the bug related to this poster's Def Qry only?

I'm running into similar problem trying to update a field to nullable = false.

0 Kudos
JohnMarino
New Contributor III

The issue appears to be with having a Definition Query applied to the Feature Layer View when attempting to update its 'definition.'

In case anyone else encounters this error message, here is a workaround that was successful for me:

  1. remove all definition queries for the feature layer view [edit: be sure to save your definition queries for later retrieval, or at least remember what they are]
  2. update the definition of the feature layer view
  3. re-enable any definition queries previously removed in step 1
by Anonymous User
Not applicable

I had the same exact issue as described by Tom Rippetoe‌ and this 3-step process worked like a charm. I hope there's a bug fix coming soon on this or at least a more useful error. Anyway, in my opinion this should replace the current Correct Answer as it provides an actual workaround rather than a link to a promise of fix. Thank you for sharing, John Marino!

Trippetoe
Occasional Contributor III

Works for me. i updated the correct answer.

MichaelVolz
Esteemed Contributor

Thanks for sharing that information John.  That is the best part of GeoNet!!!!

RobBurke
New Contributor III

How do you carry out the first step?  "remove all definition queries for the feature layer view"

 

Robert Burke
fklotz
by
Occasional Contributor

Steps that worked for me:

  1. Navigate to the ArcGIS REST Services Directory page for the specific layer within your Hosted Feature Layer
  2. Use the "deleteFromDefinition" REST end point, passing it both the "viewDefinitionQuery" and the "definitionQuery" from the layer in your view. e.g., 

 

{
"viewDefinitionQuery" : "(field1 = 12345) AND (field_name_two = 'bobsyeruncle')",
"definitionQuery" : "(field1 = 12345) AND (field_name_two = 'bobsyeruncle')"
}​

 

  • After step 2 is complete, use the "addToDefinition" REST end point, passing it ONLY the "viewDefinitionQuery", ESRI will add the "definitionQuery" for you automatically. If you try to pass both, you will get the "Invalid definition for System.String" error.

 

{
"viewDefinitionQuery" : "(field1 = 98765) AND (field_name_two = 'slurm is tasty')"
}​

 

Farley
ArmstKP
Occasional Contributor III

This bug still exists as of today.