Showing posts with label SharePoint 2010. Show all posts
Showing posts with label SharePoint 2010. Show all posts

Thursday, November 8, 2012

Remove Destination Folder from Upload File dialog

After upgrading from 2007 to SharePoint 2010 we noticed that the upload dialog now has a destination folder field to allow to select a destination folder in SharePoint.

The client requested this destination folder to be removed.

I found the following blog to be a great help, http://digsharepoint.blogspot.com/2011/06/destination-folder-field-in-site.html

I have included an extract from this blog as I have come across many blogs that reference a solution and the link no longer works or the web page / blog has been removed.

"A Google search on this led me to this very informative and helpful blog by Brian McCullough. It looks like that this behavior is due to the different values that are assigned to the vti_foldersubfolderitemcountproperty in the Folder's property bag for an upgraded object versus a new object.

For upgraded objects, this property’s value is set to 1.
For new objects, this property’s value is set to 0.

Also, the upgrade process sets the SPWeb.CustomUploadPage property for upgraded sites to a custom upload page titled uploadex.aspx, as opposed to upload.aspx which is the default page for file uploads. And this custom upload page contains the “Destination Folder” field.
... Brian provided a PowerShell script in his blog that loops through all Web sites that are contained within the site collection, including the top-level site and its subsites, and checks to see if the SPWeb.CustomUploadPage property is not equal to blank. If true, then it sets the SPWeb.CustomUploadPage property to blank. Doing so, removes the custom upload page (uploadex.aspx) from SPWeb, and reverts back to the default upload page (upload.aspx), which does not contain the “Destination Folder” field. 

Here is the PowerShell script to remove the custom upload page (containing the Destination Folder field):

foreach($webapp in get-spwebapplication)
{
foreach($site in $webapp.Sites)
{
foreach($web in $site.AllWebs)
{
if ($web.CustomUploadPage -ne "")
{

Out-File C:\Logs\WebsWithDestinationFolder_Log.txt -Append -InputObject $web.Url

$web.CustomUploadPage = ""
$web.Update()
}
}
}
}

"

Tuesday, May 22, 2012

Find Feature name from Feature ID

I received the following error:
The site collection requires feature {791fce91-700e-4219-b432-52d5c10874b2} to be activated.

I found this simple but helpful tool which provides the feature name from the ID to help identify which feature needs to be activated.

http://featurenamefromid.codeplex.com/

Makes the task a little bit easier.

Friday, April 13, 2012

Error when trying to create new Uri using value from SPListItem[“FileRef”]

I have taken over maintenance of a SharePoint solution recently deployed to SharePoint 2010 (which was previously running on SharePoint 2007).
It has a timer job that runs checks unprocessed items in a library, if it has more than 5 attachments, it proceeds to great a compressed file for these items. Within this procedure it uses the SPListItem[“FileRef”] to create a new Uri. When it does this I get the following error:

Message: Error attaching files: , Invalid URI: The format of the URI could not be determined. at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind) at …

According to the uses this was working before in SharePoint 2007. The reason it fails is because the SPListItem[“FileRef”] returns a relative url.
I have amended this to use the Encoded Abs Url, so that my code now looks like this:

lst.FileURL = item["ows_EncodedAbsUrl"].ToString();

This works.