Monday, December 10, 2012

SharePoint 2010 Best Practices: Asset Versus Picture Library

If you have pictures, you have the choice to either store them in an asset library or a picture library. What is the best practice here?

Asset library (a media library)
More info about the asset library: http://office.microsoft.com/en-us/sharepoint-server-help/set-up-a-library-to-store-image-audio-or-video-files-HA101828004.aspx  Pros:
- Has in-built support for the new digital asset content types: image, video, and audio files.
- Has a default thumbnail-centric view.
- Has an image preview.
- Supports automatic metadata extractions (and promotion) for the following image types: BMP, GIF, ICO, JPEG, PNG, and TIFF.
- Podcasting support thru RSS feature.
- Supports metadata navigation (see https://www.nothingbutsharepoint.com/sites/eusp/Pages/SharePoint-Asset-Library.aspx  )
- Has a standard SharePoint 2010 menu (and therefore, has ribbon support).
-Centralized repository setup for digital assets (image, video, and audio files) for the organization.
- Allows Edit in Datasheet View, the Picture library does not. This makes bulk metadata management a lot easier.
Cons:
- Does not create a slide show of the pictures. This is an often used feature in Intranets. Example: A news article with a direct link to the slide show view of your company's last event or party.
- Although it is possible to email a link to the file (as is also the case in a Picture library), you can't easily embed them in an email or Word document. If you want to do this, you need to manually download the files you want to embed and add them manually to the email/document.
Picture library
More info about the picture library: http://agsci.psu.edu/it/how-to/use-picture-library-in-sharepoint-2007  Pros:
- Has a slideshow view of the pictures it contains.
- Can only contain pictures and is optimized for that.
- you can embed a picture directly into an email or Office document using the "Send To" action menu item.
- You can use the /_vti_bin/imaging.asmx web service to execute Upload/Download and other operations related to picture libraries: http://msdn.microsoft.com/en-us/library/imaging.imaging_members(v=office.12  ). Asset libraries don't have such a service.
With a Picture Library, users can easily send pictures (one or more) in an email (embedded in the body or as an attachment) or automatically add them to a Word document. With an Asset Library, users must download the files and manually create the email / document. Both have the option email a link to the file.
Cons:
- Does not have the larger thumbnail option of a picture when you hover over the item.
- The library menu is 2007 style, and thus looks different from other SharePoint 2010 libraries.
- Has a complicated way of uploading pictures using the "Picture Manager" application.

Conclusion
For pictures, the asset library represents the new choice towards the Digital Asset Management way of working SharePoint is striving towards. For pictures, it's the preferred choice, unless you really need a slideshow view. For other types of content, the asset library is the way to go.

Credits:
This Wiki page was inspired by the discussion at http://social.technet.microsoft.com/Forums/en-US/sharepoint2010general/thread/1272cf0c-095f-40d5-bde1-49f1fff70ba1Please note: Also check out the SharePoint 2010 Best Practice Overview page athttp://social.technet.microsoft.com/wiki/contents/articles/8666.sharepoint-2010-best-practices-en.aspx

More:
http://office.microsoft.com/en-us/windows-sharepoint-services-help/working-with-sharepoint-picture-libraries-HA001123335.aspx

https://www.nothingbutsharepoint.com/sites/eusp/Pages/An-Interesting-Thing-About-SharePoint-Picture-Libraries.aspx

Open an HTML or PDF files in SharePoint 2010


When you try to open a PDF file it prompts you to save it rather than opening.
Opening PDFs in SharePoint 2010
This is a security feature of SharePoint 2010 by design which adds headers that force the browser to download certain types of files like PDF, HTML etc. The forced download improves security for the server by disallowing the automatic execution of Web Content that contributors upload. In 2010 where we have a JavaScript Object Model, this would be a big problem if we did not have this restriction in place. This should be disabled at web application level which means across all the site collections, we cannot do at site level or site collection level.
If we disable this feature, we might have issues mainly if users try to upload HTML or other files which contain some malicious scripts.
If we want to enable this, we need to make sure that the users are not uploading any scripts (mainly Javascript) directly to Production without any testing on TEST environments.
Never fear there is a solution. It’s in central admin.Go there and click ‘Manage Web Applications’
Opening PDFs in SharePoint 2010Click on the web app you want to change, and go to ‘General Settings’
Opening PDFs in SharePoint 2010Scroll down the list until you reach ‘Browser File Handling’
Change the radio box from Strict to Permissive.
Opening PDFs in SharePoint 2010Click ok.
Go back to your PDF document and click on it – and it will open up without forcing you to save it somewhere first.




Retrieve all the files in a folder and their subfolders using VBScript or C#

To get all the files in folders and their subfolders of a given directory in an hirarchial format into a text file

' VBScript

1. Create a .txt file and paste the below vbscript code into that and save the file with .VBS extension.
2. Change the source folder path and destination path.
3. Then double click on the .vbs file, it will take few seconds and generate a text file with the details on the given path.

Dim oFSO, oFldr

set oFSO = CreateObject("Scripting.FileSystemObject")
Call Folders()

Function Folders()
set oFldr = oFSO.GetFolder("D:\Projects")
call GetSubFolders()
End Function

Function GetSubFolders()
for each files1 in oFldr.Files
call WriteFile(oFldr.Path & " " & files1.name)
Next
for each subFldr in oFldr.SubFolders
for each oFldr in subFldr.SubFolders
Call GetSubFolders()
next
for each files in subFldr.Files
call WriteFile(subFldr.Path & " " & files.name)
Next
next
End Function
'This works for both .txt & .xls. To use it for xls, just change the extension below to .xls.
Function WriteFile(strFiles)
if not oFSO.FileExists("D:\Projects\FilesIndex.txt") then
set f = oFSO.CreateTextFile("D:\Projects\FilesIndex.txt",1)
Else
set f = oFSO.OpenTextFile("D:\Projects\FilesIndex.txt", 8)
End if
f.WriteLine(strFiles)
f.close()
End Function


' In C# code for the same..
    'private void Folders()
    '   {
    '       DirectoryInfo dir = new DirectoryInfo("D:\\SiteMaker\\Root\\");
    '       //DirectoryInfo dir = new DirectoryInfo("D:\\SiteMaker\\images");
    '       GetSubFolder(dir);
    '   }

    '   private void GetSubFolder(DirectoryInfo dir)
    '   {
    '       foreach (FileInfo files1 in dir.GetFiles())
    '       {
    '           strFiles.Add(files1.FullName);
    '       }
    '       foreach (DirectoryInfo subDir in dir.GetDirectories())
    '       {
    '           foreach (DirectoryInfo dir1 in subDir.GetDirectories())
    '           {
    '               GetSubFolder(dir1);
    '           }
    '           foreach (FileInfo files in subDir.GetFiles())
    '           {
    '               strFiles.Add(files.FullName);
    '           }
    '       }
    '   }

Thursday, December 6, 2012

SharePoint 2010: An error occured while rendering navigation for requrested URL. Exception message: Cannote complete this action.


An error occurred while rendering navigation for requested URL. Exception message: Cannot complete this action.Microsoft.SharePoint.SPGlobal.HandleComException...

One of the user was reported with the above error message while accessing a SharePoint 2010 Publishing site.


The actual root cause of the issue the Navigation Settings. When I try to open the navigation settings page (/_layouts/AreaNavigationSettings.aspx) on the site, we are getting an "Server Error in '/' Application". This is the second time I was reported on the same sort of issue, but this time from a different user on different site (even different site collection, but on the same web application). And again the user was not sure which page/s were causing the issue.
Based on the recent modified pages in reverse order, I keep going deleting them as I know that I can restore them back once the issue fixed. As soon as I deleted the issue causing page, I was able to access all the settings pages including Navigation Settings. Then I went and deleted the page URL in the Navigation Settings section and restored all the pages which were deleted including the root cause page as the issue was not with the page, issue was with the Navigation URL of the page. Not sure exactly what was the issue with the Navigation URL as it looked good to me before I removed.
There I observed an uncommon behavior at Global Navigation settings like the page which was causing the issue with its name, few folders were added. I just deleted them and monitored for some time, that did not repeated. Happy ending....

Please see more information on the same issue:
SP 2010: Error when opening _layouts/AreaNavigationSettings.aspx

Imp: Avoid adding a document URL or List/Document Library URL to site Navigation (if it has a mile long) instead place it in a page and use that page URL in the Navigation.