When I deactivate workflow feature or retract the workflow solution, I'm unable to delete the status column of the workflow from the list. I have tried these ways:
- From the web interface - List settings. When deleting the column, a runtime error occurred.
- From Sharepoint management shell, still no hope,
- By creating console Application. This is my custom code:
using (SPSite site = new SPSite("mysite")) { using (SPWeb web = site.RootWeb) { SPList list = web.Lists["mylist"]; SPField fld = list.Fields["myfield"]; fld.Hidden = false; fld.ReadOnlyField = false; fld.Update(); list.Fields.Delete(fld.InternalName); list.Update(); } }
SPException is being thrown, with the message "Cannot complete this action." I've tried impersonation and elevated privileges, too, with no hope, SPField.Delete() and SPField.AllowDeletion also don't help.
Using SharePoint designer causes the error above, too.
I have deleted all the workflow associations from the list, so the count of list.SPWrokflowAssociations.Count = 0;
Can someone explain the reason of this strange behavior and how can I delete such fields?