Azure DevOps and "VS402846: The number of picklists in the collection has reached the limit of 2048"
Posted on: January 8, 2024Many companies have customized their Azure DevOps processes over the years.
You can do that by going to the Organization Settings
and then Process
:
There you can see the list of processes that you have in your organization. You can then also view the fields that you have in use in your processes:
If you open up one process and then workitem type, you can then add new fields to the workitem type:
If you do all this manually, then most likely you don’t easily get yourself to
a situation where you have too many fields. Especially, just picklist
fields.
However, if you are trying to migrate your process from one organization to another by using the VSTS Process Migrator for Node.js tool, then you might hit this problem. Here is link to the tool:
It has issue #47 which has this exact problem described. Migration fails with error:
VS402846: The number of picklists in the collection has reached the limit of 2048
This happens if you need to re-run the migration process multiple times for testing or for some other reason. Migration process creates new fields early in the process and if you hit some another issue, those fields are left behind and not cleaned up. These fields are ghost fields since they are not visible in the user interface, but they are still there. Running the migration process again will create new fields and then you will eventually hit the limit of 2048 fields.
You can easily replicate this by deleting the field from the user interface:
The above field is now deleted from the user interface, but it is still in the database.
To fix this, you need to use Azure DevOps REST API to delete the fields.
I’ve developed a small PowerShell script that you can use to delete the fields.
Process is quite simple. First, we export the list of fields to Excel file:
Export file looks like this:
As you can see, first row does not contain DisplayName
, ReferenceName
or
the other details, so it’s our phantom field that we need to delete.
We mark ToBeDeleted
column of that first row to Yes
and save the file and close Excel:
Script shows all the rows to be deleted and asks confirmation before proceeding:
Script now deletes the selected fields:
You can find this script here:
I’ve on purpose set that delete part to be commented out in the example script, so that if you’re testing, then it won’t do anything unless you uncomment that part.
Remember to be extra careful when deleting fields from your organization!
I hope you find this useful!