Delete a read-only column from a list/library in SharePoint Online
-
14-02-2021 - |
题
I have a column of type workflow status that is present in some but not all document libraries in a site. When I use power automate to move these files, I am met with an error that says the move failed due to a missing column of type workflow status.
Here is the column in SharePoint designer:
This is what I see when I try to delete in in SharePoint designer:
There is no option to delete this column in SharePoint Online, I have already disabled all SharePoint workflow related features on this site.
Is there a way to delete read only columns from SharePoint Lists/Libraries?
解决方案 3
Was able to delete the column by using a powershell module SPOMod
Workflow status columns may be deleted using the cmdlets in this module, or by setting the read-only property to false, following with manual deletion using sharepoint designer. This is the second method:
First install this SharePoint Online SDK (Choose sharepointclientcomponents_16-6906-1200_x64-en-us.msi, the other one does not work.)
Download and extract the script from here
Import that script into this following program and run it to set the read-only property of all workflow status columns to false:
Add-Type -Path (Resolve-Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll")
Add-Type -Path (Resolve-Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll")
Add-Type -Path (Resolve-Path "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll")
import-module {{SPOMod Location}
$UserName = {{your username}}
$Url = {{your site}}
Connect-SPOCSOM -username $UserName -url $url
$lists = (Get-SPOList -IncludeAllProperties | where {$_.BaseType -eq "DocumentLibrary"}).Title
foreach($list in $lists) {
write-host "List: $($list) \n"
$fields = (Get-SPOListFields -ListTitle $list).Title
foreach($field in $fields){
$c = Get-SPOListColumn -ListTitle $list -FieldTitle $field # | export-csv .\$($list).csv -Append
$xml = [xml]$c.SchemaXML
if ($xml.Field.Type -eq "WorkflowStatus") {
$xml
set-spolistcolumn -ListTitle $list -FieldTitle $field -ReadOnlyField $false
}
}
}
After this script has run, you can open the libraries in SharePoint Designer and delete the columns successfully.
其他提示
This looks like a SharePoint 2010 or 2013 workflow is associated with this list/library. The column has been created by the workflow and you cannot delete it while the workflow is still associated with the list/library. It is not sufficient to disable SharePoint workflow features.
You need to edit the list/library in SPD and delete the actual workflow.
Go to list/library settings> workflow settings> remove the workflow you don't need.
Then try to delete the column again to compare the result.