Select to view content in your preferred language

AddFields GP tool Limits the number of fields added to a table?

634
4
Jump to solution
02-20-2023 11:29 AM
AdamStevens81
Emerging Contributor

I have been looking into an issue when inserting records into a table through an Add-In developed using the Pro SDK. The error encountered is an index out of range error when creating the rowbuffer object prior to inserting the records.

I've discovered that this is caused by the AddFields GP tool failing to add all of the fields that are passed into it. The AddFields GP tool seems to cap out at adding about 85 fields to the table. Confusingly, this remains the same if I pass in one large parameter object containing all the fields, or if I break the object down into chunks e.g 50 fields per iteration. This doesn't make any sense, so I was wondering if there was a known limitation with how the AddFields GP tool adds fields to the table?

The workaround for running the AddField tool for each field isn't really feasible since it takes a long time to add 80+ fields.

Below is the function used to call the GP tool. This function works just fine for any other scenario.

AdamStevens81_0-1676921250560.png

 

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
AdamStevens81
Emerging Contributor

It's been a little while since I posted this issue but I wanted to come back to it and close it out.

@StephenRhea_NV5 , @Wolf , the problem was that there was a duplicate fieldname error that was not caught by error handling. It took a bit of digging to determine that this was the problem, so once error handling was fixed to handle that case, I was no longer running into issues with adding fields beyond an arbitrary limit.

Thanks for your input, and fortunately there is no issue on the SDK/geoprocessing side here to deal with.

View solution in original post

0 Kudos
4 Replies
StephenRhea_NV5
Frequent Contributor

Do any of the fields get added? I have a routine that adds 178 records (total string length of 6,940 characters), and I haven't had any issues. Seems like a field definition may need special formatting (quotations marks, slashes, etc.) or be incorrectly named.

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

Given that @StephenRhea_NV5  was able to add 178 fields i would second his guess that some field definitions are not defined as required.  To work around this, I would try to use DDL (SchemaBuilder) to add your fields.  It's easier to declare your field definitions since you can define fields using the FieldDescription class.   ProConcepts DDL · Esri/arcgis-pro-sdk Wiki (github.com)

There is also a code snippet: ProSnippets Geodatabase · Esri/arcgis-pro-sdk Wiki (github.com)

and you can look at this example:  arcgis-pro-sdk-community-samples/Geodatabase/DDLAddField2FeatureClass at 6078006a3943364f2a7931b19d1...

 

0 Kudos
StephenRhea_NV5
Frequent Contributor

I should note that I'm using Pro 2.9.5; @AdamStevens81 which version are you using? Another diagnostic step could be to use the AddField as you mentioned just to make sure the definitions are correct.

0 Kudos
AdamStevens81
Emerging Contributor

It's been a little while since I posted this issue but I wanted to come back to it and close it out.

@StephenRhea_NV5 , @Wolf , the problem was that there was a duplicate fieldname error that was not caught by error handling. It took a bit of digging to determine that this was the problem, so once error handling was fixed to handle that case, I was no longer running into issues with adding fields beyond an arbitrary limit.

Thanks for your input, and fortunately there is no issue on the SDK/geoprocessing side here to deal with.

0 Kudos