Incompatibility Error When Deploying a List That Used to Contain a SharePoint Workflow

  • 16 February 2021
  • 0 replies
  • 14 views

Badge +1

Issue

When deploying a K2 solution that uses a SharePoint list, an incompatibility error is displayed regarding a Workflow Status column. This issue occurs when there was once a SharePoint workflow associated with the list that has since been deleted. The property cannot be deleted from the SharePoint list settings page and only shows when editing views for the list. 

17972iFE618769A3C32D47.png

 

Resolution

The orphaned Workflow Status property can only be removed through the use of code. The below code can be altered and ran in Visual Studio to remove the property. Once the property is removed, the K2 SmartObjects, views, and forms will need to be regenerated from the K2 Application page for the list before creating a new package in order to clear the error seen while deploying. 

using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.SharePoint; namespace DeleteSPListColumns { class Program { static void Main(string[] args) { using (SPSite spSite = new SPSite("SITE_URL")) { using (SPWeb spWeb = spSite.RootWeb) { SPList isoDocs = spWeb.Lists["LIST_NAME"]; SPField field = isoDocs.Fields[new Guid("GUID_VALUE")]; Console.WriteLine("Field Name:" + field.InternalName); field.Hidden = false; field.ReadOnlyField = false; field.Update(); isoDocs.Fields.Delete(field.InternalName); Console.WriteLine("Field deleted - Done!"); } } Console.WriteLine("You may close the window ..."); Console.Read(); } } }

Note: It is strongly recommended to take a backup of your SharePoint database before performing this as the code makes a direct change outside of the SharePoint UI.  

 

Replace SITE_URL with the URL to your SharePoint site and LIST_NAME with the name of the list where the issue is seen. The following commands can be run in the SharePoint Management PowerShell to retrieve the GUID for the orphaned property which can then replace GUID_VALUE in the above code. 

  • $web = get-spweb SHAREPOINT_SITE_URL
  • $list = $web.lists["LIST_NAME"] 
  • $list.fields["PROPERTY_NAME"].id (use the property name from the error) 
  • $web.dispose()

Additional Information

The Visual Studio project will need to be built using .NET Framework 4.5 for SharePoint 2013 and 2016, otherwise there will be errors when the project is compiled. Additionally, you will need to add the following references to the project which can be found in C:WindowsMicrosoft.NETassemblyGAC_MSIL from the SharePoint server: Microsoft.SharePoint.dll, Microsoft.SharePoint.Client.dll, and Microsoft.SharePoint.Client.Runtime.dll. 


0 replies

Be the first to reply!

Reply