Introduction
I am getting an error message as the URL is invalid or it may refer to a nonexistent file or folder, or refer to a valid file or folder that is not in the current Web. This error occurs when we create new document library and try to upload a document on it, else try to check in the document. The existing document libraries work fine with getting any error message.
Background
I tried the following ways to fix the issue:
- Verified the content type whether any duplicate columns are created or not
- Deactivated the custom content type solution and tried to upload the document
- Removed custom content type which is attached in the document library
- Tried to find out the issue on the log file
- Finally, I got Powershell script to resolve this issue
This issue occurred, duplicate column was created in the basic item content type.
Using the Code
Execute the below Powershell script in your SharePoint server to delete the duplicate column in the base content type.
if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) {
Add-PSSnapin Microsoft.SharePoint.PowerShell;
}
$url = 'https://site.url.com'
Disable-SPFeature -Identity Fields -url $url -force
Enable-SPFeature -Identity Fields -url $url
$Site = get-spsite $url
foreach ($web in $site.allwebs)
{
$lists = New-object System.collections.arraylist
$web.Lists | % { $lists.add($_) } | Out-Null
foreach ($list in $Lists)
{
$AuthorField = $list.fields.getfieldbyInternalName('Author')
if ( $Authorfield.schemaXML -notmatch "FromBaseType" )
{
Write-host $web.url $list.title -Separator `t`t
$xml = [xml]$AuthorField.SchemaXmlWithResourceTokens
$xml.Field.SetAttribute('FromBaseType','TRUE')
$AuthorField.SchemaXml = $xml.OuterXml
$AuthorField.Update()
}
}
}
$Site.Dispose()
After executing the above script, restart your IIS.
Points of Interest
I wasted lot of time to resolve this issue. I hope it will be helpful for you to resolve this issue within 2 to 3 minutes.
Please let me know if you are still facing the same issue.
History
- 4th July, 2016: Initial version created