ArcGIS Pro Truncate Table GP Tool Could Work on Portal Hosted Feature Layer

1948
11
07-19-2022 05:09 PM
Status: Already Offered
Labels (1)
TimMinter
Occasional Contributor III

Truncate Table GP tool would work faster than the Delete Features GP tool, and it would reset the ObjectID values instead of incrementing them from the highest number left over from Delete Features.

That would surely be better.

Cheers,

tim

11 Comments
jcarlson

Check out FeatureLayer.manager.truncate() in the Python API, it should do what you want.

KoryKramer

@TimMinter https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/truncatetable.htm supports feature services starting in ArcGIS Pro 3.0. The help says 

  • This tool supports a feature service layer as input when connected as a user that can administer the service and the supportsTruncate service property is true.

I understand that you are referring to Portal but I just tried this on an ArcGIS Online Hosted Feature Service and truncate worked. What versions of Pro and Enterprise are you on?

TimMinter

I like it, @KoryKramer !  If you all can complete and release my ideas faster than I can have and post them, then I think we're where we need to be 🙂

So, I'm at ArcGIS Pro 2.9.3 and ArcGIS Enterprise 10.9.1.  We don't deploy Esri dot zero releases, and it looks like AGP 3.0.x will require some planning and finagling to make the jump, so...  it will be awhile.

Nice,

tim

TimMinter

good info @jcarlson .  It could work for me, but maybe not for others for whom I'm hacking a path through the underbrush.  Another idea I have, but have to review a bit before posting, is that GP tools should all work consistently and as documented:

  • alone
  • in a ModelBuilder model
  • in a Python script exported from a ModelBuilder model
  • in a "from scratch" Python script

I've found several situations that I think break that continuum... but for another post at some point when I have time.

thanks!

tim

KoryKramer
Status changed to: Already Offered

Got it, Tim. Well, Truncate Table on feature services should be ready for you when you're able to get upgraded. We understand the need to test, plan, finagle etc. before moving to a major release. Please read https://www.esri.com/arcgis-blog/products/arcgis-pro/announcements/get-ready-for-arcgis-pro-3-0/ and the help referenced from there as you plan your move to 3.x.

LindsayRaabe_FPCWA

@KoryKramer I'm at my wits end here. I had a layer published where supportTruncate = true but I can't repeat it !!! And I can't find any documentation anywhere that references how to make this setting supported. How can I use the Truncate Tool on a feature service if I can't change the service setting to support Truncate? 

I've tried publishing from ArcGIS Pro directly from the layer, sharing the webmap as a layer, with editing turned on, turned off, sync on, sync off, update the settings through the "Update Definition" option. Nothing seems to work. It seems like a frozen setting! (running ArcGIS Pro 3.1)

PeterHodkinson

Hi @LindsayRaabe_FPCWA,

I also noticed recently that I couldn't update the supportsTruncate property of an ArcGIS Online hosted feature layer using the REST API Update Definition function, despite getting a successful response to the operation. As a result, I had a bug logged for this behaviour which is currently in review. This is logged as BUG-000155843. 

I hope this is helpful information for you, although I'm afraid I've not found a workaround for this yet so can't fully answer your question.

Best wishes,

Peter

RussellBrennan

@LindsayRaabe_FPCWAHave you seen this doc: https://developers.arcgis.com/rest/services-reference/online/truncate-feature-layer-.htm

My understanding is that you cannot set this property, rather it will be true if the following conditions are met.

1. you need to be running Truncate as owner (publisher) of the feature layer or a portal administrator to be able to truncate

2. the layer cannot have sync or change tracking enabled.

3. the layer cannot have relationships with other layers

4. the layer cannot be a view layer or be a hosted layer that other view layers are created off of.

I am trying to get confirmation on my statements above to make sure I am correct.

LindsayRaabe_FPCWA

@PeterHodkinson Thanks for your info. I've tried updating them too through the Admin page and UpdateDefinition button, but same as you - no change despite a supposedly successful update. I'll subscribe to that bug. Do you have any idea on how to publish a new layer where the supportsTruncate property is set to True in the 1st instance?

@bruss I hadn't looked at that link, only this one: Truncate Table (Data Management)—ArcGIS Pro | Documentation which is the tool I'm trying to use. It makes no mention in there about sync, change tracking or hosted views. 

  • Supported data types are simple points, lines, or polygons stored in a database. Complex data types such as terrains, topologies, and network datasets are not supported as input.

  • The input database table or feature class must be from a database connection established as the data owner.

  • Versioned data is not supported as input. Data must be unregistered as versioned before the tool will run successfully.

  • Truncate commands do not use database transactions and are unrecoverable. This improves performance over row-by-row deletion.

  • It is recommended that you use this tool for workflows in which all rows are removed from a table or feature class and there is no need to back up the transactions, such as nightly reloading of data.

  • This tool supports a feature service layer as input when connected as a user that can administer the service and the supportsTruncate service property is true.

  • This tool does not support feature classes with attachments. To delete rows from a feature class that has attachments, use the Delete Rows tool.
PeterHodkinson

Hi @LindsayRaabe_FPCWA sorry, I'm not sure about that I'm afraid. I'd be interested to know too!