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:
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?
Solved! Go to Solution.
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:
Esri Tech Support has verified that this is a bug in AGOL. The bug number is #BUG-000114175
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.
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:
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!
Thanks for sharing that information John. That is the best part of GeoNet!!!!
The latest BUG on this is marked as "By Design". The fix is quite easy to implement, but it is annoying that Esri's error messaging is not better or that the updateDefinition doesn't take care of these things by itself.
From the bug page:
Submitted | January 25, 2023 |
Last Modified | October 12, 2023 |
Applies to | ArcGIS Online |
Version found | November 2022 |
Operating System | Windows OS |
Operating System Version | 11.0 64 bit |
Status | As Designed |
When updating a layer definition from REST, it is recommended to only include the part of the definition that is being updated. Including the entire definition may cause the update definition to fail. The "definitionQuery" cannot be updated by updating the layer definition. However, you can update the "viewDefinitionQuery" without including the rest of the layer definition including the "definitionQuery".
End of bug page content.
What this means is when you update the definition query, you only need to include the elements you want to update. For example, if the bottom of my layer's definition shows:
"maxRecordCount" : 1000,
"standardMaxRecordCount" : 32000,
"tileMaxRecordCount" : 8000,
"maxRecordCountFactor" : 1,
"capabilities" : "Query",
"viewDefinitionQuery" : "CreationDate > timestamp '2023-01-01 05:59:59'",
"definitionQuery" : "CreationDate > timestamp '2023-01-01 05:59:59'",
"exceedsLimitFactor" : 1,
"layerOverrides" : [
"allowGeometryUpdates",
"capabilities",
"ownershipBasedAccessControlForFeatures"
]
}
and I want to modify the maxRecordCount and the view's definition query, I would submit the following to the updateDefinition end point:
{
"maxRecordCount" : 5000,
"viewDefinitionQuery" : "CreationDate > timestamp '2024-01-01 05:59:59'"
}
Looking at the layer definition afterwards, we can see that those elements have been updated:
"maxRecordCount" : 5000,
"standardMaxRecordCount" : 32000,
"tileMaxRecordCount" : 8000,
"maxRecordCountFactor" : 1,
"capabilities" : "Query",
"viewDefinitionQuery" : "CreationDate > timestamp '2024-01-01 05:59:59'",
"definitionQuery" : "CreationDate > timestamp '2024-01-01 05:59:59'",
"exceedsLimitFactor" : 1,
"layerOverrides" : [
"allowGeometryUpdates",
"capabilities",
"ownershipBasedAccessControlForFeatures"
]
}
Steps that worked for me:
{
"viewDefinitionQuery" : "(field1 = 12345) AND (field_name_two = 'bobsyeruncle')",
"definitionQuery" : "(field1 = 12345) AND (field_name_two = 'bobsyeruncle')"
}
{
"viewDefinitionQuery" : "(field1 = 98765) AND (field_name_two = 'slurm is tasty')"
}