Tuesday, May 1, 2012

Display the Quick Launch in a SharePoint 2007/2010 Web Part /Publishing page

Many thanks to Christophe for a wonderful script to display quick launch in a web part page (original post/source post). I have re-written/adjusted Christophe’s code to work around issues with SharePoint 2010 upgrade. The current code works only in SharePoint 2010. I made some changes to the code to make it workable in SharePoint 2007 and 2010 pages. So, the same code works seamlessly after SharePoint 2010 upgrade. I have also simplified the code to easily understandable and to use across the site collection with some minor tweaks.
Here is the updated code:

Copy the below mentioned code into a notepad and save the file as DisplayQuickLaunch.js file. Upload the JS file your site collection level scripts/documents library.
function DisplayQuickLaunch()
{
 //Check for SharePoint Version
 var QuickLaunch =""; 
 if (typeof _fV4UI == "undefined") 
 {
  QuickLaunch = "LeftNavigationAreaCell";
 }
 else
 {
  QuickLaunch = "ctl00_PlaceHolderLeftNavBar_QuickLaunchNavigationManager";
 }
 
 var placeholder = document.getElementById(QuickLaunch);
 var quicklaunchmenu = null;
 var SourcePage = document.getElementById("SourcePage"); 
 try {
    if(SourcePage.contentDocument)
       // Firefox, Opera
 
       {quicklaunchmenu = SourcePage.contentDocument.getElementById(QuickLaunch) ;}
    else if(SourcePage.contentWindow)
       // Internet Explorer
 
       {quicklaunchmenu = SourcePage.contentWindow.document.getElementById(QuickLaunch) ;}
    else if(SourcePage.document)
       // Others?
 
       {quicklaunchmenu = SourcePage.document.getElementById(QuickLaunch) ;}
 }
 catch(err) { alert ("Loading failed");}
 placeholder.innerHTML = quicklaunchmenu.innerHTML;
}
Once you are done with the upload, copy the below mentioned code into to a content editor web part in SharePoint 2007 or HTML Form web part in SharePoint 2010. Make sure to update site URL and JS file path.


<iframe id="SourcePage" onload="DisplayQuickLaunch()" src="http://[Your Site]/default.aspx" style="display: none;"></iframe>

<script src="https//[Your JS file path]/DisplayQuickLaunch.js" type="text/javascript">
</script>
Hope this helps.

Tuesday, August 16, 2011

SharePoint Document library Versioning and Recommended Practices

Based on a discussion with my colleague about SharePoint document library versioning, I thought of writing a blog post on SharePoint versioning recommended practices. By default, version history is turned off on document libraries. My own recommended practice is turn on versioning and limit the versions to 3 major and 3 minor versions with option to create major and minor versions. However, limiting the versions completely depends on the business requirements as well. Some business users need to keep 5 to 10 different versions based on their work strategy.

ü  Turn on Versioning with create major and minor (draft) versions
ü  Limit the versions to 3 major and 3 minor
ü  Enable require checkout functionality

Versioning is a great feature of SharePoint. We can easily restore the documents from earlier versions in case of any data loss. It provides a safety net in the event that a corrupted version gets saved and also you can track the changes (and see who made them) from version to version at a glance. This feature is not available with traditional Shared Drives. Users are used to rename the files with appended “_v1”, “_v2” etc. to maintain the versions in Shared Drives. So, I would definitely enable the versioning in SharePoint document libraries and limit the versions to 3 major and 3 minor versions.

Major and Minor Versions: Versions ending with a zero extension (.0) are major versions and versions ending with non-zero extensions are minor versions. Only major versions can be published. Additional permission levels can be configured for working with minor versions (draft). In most scenarios, users who can edit major versions are also allowed to edit minor versions, but read-only users can only view major versions/published documents.

Why do I need to limit versions to 3 major and 3 minor versions?

By default, SharePoint keeps all versions in the document library once you enable the versioning (all versions size is counted towards the site collection quota), and these aren't bitwise differential versions, they're the full versions. I.e. each time you save the document, SharePoint stores as a separate copy of complete document in the database though you make a small change. Just imagine If you have a 100 MB presentation with 20 different versions (Around 2 GB of storage capacity). With large documents, even a small but active library can eat up your database in a hurry. If you have a limited site collection storage capacity, this is going to be a big issue to store more number of documents as database reaches it max storage capacity very soon. So, restrict at max 3 major and 3 minor versions at any point in time in the document library.

If you forget to set the limitation, there is no way from SharePoint out-of-the-box UI to delete specific versions form document version history. Either you have to remove/delete all versions or all minor versions. There is no way to delete specific published or minor versions in bulk.

To enable version history, follow the below mentioned steps:

v  Navigate to your SharePoint document library
v  Select document library settings
v  In the settings page, under General Settings section, click Versioning Settings
v  Check the checkbox “Create major and minor (draft) versions” option
v  And, check the checkboxes to keep 3 major and 3 minor versions

Friday, February 18, 2011

SharePoint 2007: Single Document library vs. Multiple Document Libraries

I often come across this question from customers or in forums about what is the best option to use a single document library vs. multiple document libraries in SharePoint site. However, choosing the best option is completely depends on the requirements to use single vs. multiple document libraries. There are different pros and cons associated using single vs. multiple document libraries.
What is a document library?
Document library is a location in a SharePoint site containing files of one or more content types. In SharePoint, by default everything is stored as content type. Example: By default, documents in a document library are stored with a “Document” content type. Document libraries are designed to manage and store related documents and lets users to create new documents of appropriate types.
Single Document Library :
·         Use a single document library if you have a requirement to store all of your documents in a central repository. So, you can view all the documents at one place, i.e. using group by views. Example: By Region, Country, or Year etc.
o   Permissions are not a constraint and would like to open the library for Read/Contribute permission users. i.e.  Users of the document library can see all the documents irrespective of read write permissions.
o   Require to group the documents based on specific category in a single view
Benefits for storing Documents in a Single Document Library:
·         Users can easily add new documents or find existing documents with a single document library
·         Document Management settings such as permissions, content versioning, and approval are applied at document library level
·         Multiple views can be created to view the documents in different groups and views created by using the user interface are bound to a particular library
·         Can attach Information Management policies, such as Retention, Auditing etc. to a document library level
Document Library Storage Limits:
·         The Maximum recommended size of a library is 10,000,000 documents (yes, 10 million documents).
·         Cannot apply unique document management settings such as require checkouts or versioning for specific documents.
·         Adding multiple content types to a single document library creates more confusion for the users if those content types have multiple metadata columns. To remediate this issue, use fewer content types in the document library
·         The performance of the views of content degrades when the number of items viewed exceeds 2,000 items. There are two recommendations from the Microsoft to remediate this issue.
o   Organize the content in the document library into folders each containing 2,000 of fewer.
o   Or, Create views that take advantage of indexed columns to return set of 2,000 or fewer in a view.
** I would recommend, creating views which returns 1,500 items instead of creating the folders yields the best performance. Folders cause lot of confusion, use metadata instead. **Folders are bad metadata is good!
Pros:
·         Can view different categories of documents in a single view.
·         Permissions can be managed centrally
·         Single point of truth
·         Less administrative over-head
Cons:
·         Cannot manage the permissions based on views, i.e. if user has read access to the document library, he/she can view all documents in the document library irrespective of filters, views unless you break inheritance for individual documents or use folders to restrict permissions. However, using folders or setting item level permissions is not a best practice since this complicates the permissions maintenance in long run.
·         Users may get over-whelmed with additional metadata fields need to be filled out
Multiple Document Libraries:
Use multiple document libraries if you have a requirement to restrict users from specific type of documents. Need to fill less metadata values by users. More are less like folders structure.
Pros:
·         Easy to setup the libraries
·         Less adjustment for user, as it is more like a folder structure
·         Unique permissions can set on individual document libraries
Cons:
·         More administrative over-ahead, as settings need to be configured on individual document libraries such as versioning, check-out, and information management policies etc.
·         Cannot view all documents in a single view or by grouping

Friday, February 4, 2011

Managed Metadata and Hierarchical Dropdowns

Cascading/Filtered dropdowns is the most required feature for SharePoint 2007 users which is not available by OOTB (out-of-the-box-). There are many third party custom features available to provide this functionality for cascading the metadata values from one to many levels. Most of you aware of Data cogs solution for the same.  Unfortunately, Microsoft has not introduced the cascading functionality out-of-the-box in SharePoint 2010 as well. However, using managed metadata feature and metadata taxonomy /enhanced lookup columns, we can simulate the similar behavior. But this is only a workaround since user has to drill down the taxonomy tree view to select the appropriate cascaded/filtered value. In this article I am going explain the hierarchical functionality using managed metadata.

What is Managed Metadata?

Managed metadata is a hierarchical collection of centrally managed terms that you can define, and then use as attributes for items in Microsoft SharePoint Server 2010. A term is a word or a phrase that can be associated with an item and term sets are collection of related terms in SharePoint Server 2010.
SharePoint Server 2010 includes the Term Store Management Tool, which you can use to create and manage term sets.  A user requires appropriate permissions to use the term store management tool.
Example: You can create a term set for Finance department which includes metadata related to Country, State, City and Financial Institution etc.

Using the above mentioned metadata taxonomy we can easily achieve the metadata hierarchical functionality in other way around by drilling down the tree view to appropriate metadata value.
To use the above mentioned taxonomy, create a new site column or list of type Managed Metadata. I am creating a list column to simulate the hierarchical functionality in a list.

Configure Cascading functionality with SharePoint 2010 Managed Metadata service:
I have created a new list called “Finance Contacts” and added Country, State, City and Financial Institution columns to it. Using the managed metadata columns, I am able to filter lookup values.
Here are the steps to create cascaded lookups using SharePoint 2010 managed metadata taxonomy in a list.
1.  Navigate to your SharePoint site and create a new custom list (In my example “Finance List”). Click List Settings on ribbon menu.
       
       
2.   In the list settings page, under Columns section, click “Create Column”.

3.  In the create column page, Type the name and description for the column and select the column type as “Managed Metadata”. 
                         
Note: Out-of-the-box SharePoint 2010 doesn't support direct cascading functionality with lookup lists. If you select City, it won't change the "Financial Institution" values dynamically. User has to drill down to the texanomy to get the appropriate "Financial Institution" value. At least this functionalty is very much better as compared to MOSS 2007 lookups.
4.  In the Term Set Settings section, select the Country Term set from the Finance Documents term store.

5.  Optionally you can set Default Value for the “Country” field. This functionality is not available with OOTB (out-of-the-box) SharePoint 2007 lookups. With SharePoint “Default” option available in lookups and managed metadata columns as well.

6.  Click Ok to complete the configuration.
7.  Follow the same steps 2 through 6 to create other columns State, City and Financial Intuition.
Once the all columns are configured you can see the columns view as follows.


Now you can start adding the cascaded values by drilling down to the "Country" metadata texonomy (as mentioned in the above example "Financial Institution") to the SharePoint list.

 
**Note: Out-of-the-box SharePoint 2010 doesn't support direct/dynamic cascading functionality. I.e. If you select "City" in the above example, it won't dynamically filter the values that applies to a particular City. User has to drill down to the "Financial Institution" manually from the texonomy (mentioned above) and select the appropriate filtered value. At least this is an improvement compared to MOSS 2007 lookups. User can easily drill down to the appropriate filtered metadta value using texonomy structure.



Monday, January 3, 2011

SharePoint 2010 Document Sets

Microsoft introduced a new way to manage set of documents as a single object called Document Set. This single object can be used for a workflow, metadata, information management policies. In the earlier version of SharePoint (MOSS 2007) user doesn’t have an option to collectively manage related documents as a single object to associate a workflow, metadata or IM policies and download the documents as a single object. Managing individual documents is cumbersome if documents are used for same purpose and requires same metadata, workflow etc.

In SharePoint 2010, multiple documents can be organized into document sets. Document sets are new content types in SharePoint 2010. Each document set can hold multiple documents with share same metadata. The benefit is that, for example, Project documents, which could consist of several documents related to different phases can be bundled in a document set and passed off as a set to an approval workflow. Moreover since it is a content type in itself, metadata and IM policies can be attached at document set level.
Key Benefits of SharePoint 2010 Document Sets:
Ø  Document sets can share the same metadata
Ø  Workflows can be associated to a whole document set
Ø  Manage permissions at Documents set level
 (This avoids the use of folders for managing permissions for specific documents.)
Ø  Versioning the document set instead of the separated documents
Ø  Download all documents of a document set compressed into a ZIP file
Ø  Customizable Welcome Page for all document sets
Here are the steps to create Document set in SharePoint 2010:
In order to use the Documents Sets feature, enable Document Sets Feature at Site collection level.
Navigate to your SharePoint 2010 site collection. Click Site Action and Site Settings.

Click Site Collection features.
Activate Document Sets Feature

As I mentioned in the above statements, documents sets are actually just content types as other document and list content types.
      • Create new documents Document Set content type with required metadata and workflow configurations
      • And, attach the new content type to SharePoint Document library
    Create a new Document Set Content Type:
Navigate back to your SharePoint site. Click Site Actions -> Site Settings.
Under Galleries section, select Site Content Types.
 Click Create.

Type Name and Description for the new Document Set content type and select the parent content type as “Document Set”.
Create necessary Document Set content types.
Make necessary Document Set settings according to your requirements using Document Set settings

Attach Document Set Content Types to Document Library:

Now enable “Allow Management of Content Types” on targeted document library and attach the Document Set content types.

Navigate to your document library. Click Library Settings.

Under General Settings, select Advanced Settings.

In Advanced Settings page, select "Allow Management of Content Types" as "Yes".

Now you can attach the document set content types to document library. To attach the content types, navigate back to settings page, under Content Types section, select "Add from existing site content types". 


Select the available and required Document Set content types from site content types and click Ok to attach the content types to document library.


Now you see the Document Set content types under document library new button.


Here is the snapshot of complete document set:


Document set can hold multiple and multiple types of documents with common settings and properties. This functionality is a great addition with respect to content management features in SharePoint.

Sunday, December 12, 2010

SharePoint 2010 Enhanced Lookup Columns

SharePoint 2010 provides enhanced lookup functionality which is not available with SharePoint 2007 lookup fields. When creating a new lookup column type in SharePoint2010, site admin can set up some additional columns that can pull in multiple field values from the list that is being used as the lookup. Similar functionality can be achieved in SharePoint 2007 using Business Data column, but setting up Business Data column is not that user friendly or easy as Lookup columns.
Here is a screenshot of the configuration using a lookup column in Document Library: 
When tagging/updating the metadata of documents or list items user will select only one tag and then additional columns are available in views and on view property pages.

Apart from the additional lookup fields, site admin can also enforce relationships so that it allows a cascade delete or restricts delete if a relationship still exists.
This feature is also new to SharePoint 2010. In SharePoint 2007 lookups, if anybody accidentally deletes the lookup value from the lookup list, all the lists and libraries where the lookup value is used are blanked out. Even admin doesn’t get a clue for the deleted metadata value until he/she finds it in Recycle Bin.
If there is a relationship associated with lookup and column, user cannot delete the lookup values from the lookup list. User get an error message when try to delete an item with relationship configured as Restrict delete.

Thursday, September 24, 2009

How to Backup/Restore using STSADM command

The STSADM command is used for backing up and restoring site collections. You can use this command to take the backup with full functionality and restore to new site collection. The way to backup and restore a SharePoint site using this command is:

  • Stsadm –o backup –url -filename
  • And then at a later date you can restore the site using
  • Stsadm –o restore –url -filename

Backup a Site Collection:

  • On your SharePoint server hit WINDOWS + R.
  • Type “cmd” and click OK.
  • In the cmd window navigate to the “C:\Program files\common files\microsoft shared\web server extensions\12\bin” directory.
  • Type stsadm -o backup -url “http://Server001/demo” -filename “C:\MyFirstBackup.bak” -overwrite
  • Press Enter

When the backup is completed it will now be sitting in your C:\ with the name MyFirstBackup.bak.

At this point you can copy the file to the other server, or just perform the restore on the same server by following the steps below.

Note before restoring ensure that the target site collection you are restoring onto is a BLANK site. This will allow you to avoid some potential issues with duplicate names and ID’s.

Restore a Site Collection:

  • On your SharePoint server hit WINDOWS + R.
  • Type “cmd” and click OK.
  • In the cmd window navigate to the “C:\Program files\common files\microsoft shared\web server extensions\12\bin” directory.
  • Type stsadm -o restore -url “http://Server001/Newsite” -filename “C:\MyFirstBackup.bak” -overwrite
  • Press Enter

When the restore is complete the site collection should now be replicated, or restored.

Note: STSADM is not user friendly with error messages. Check the Application Event Log. The message received in the command window may not be indicative of the true problem.

Friday, September 4, 2009

Optimizing SharePoint search using Managed Properties

I would like to discuss about Optimizing SharePoint search using Managed Properties by configuring the Properties to appear in the Advanced Search. Here are the steps to create Managed Properties and configure it in MOSS 2007 Advanced Search.

1. Go to the central administration -> Shared Services



2. Under the Search Menu, click on Search Settings.

3. In the Configure Search Settings page, click on Metadata Property Mappings.



4. In the Metadata Property Mappings page, click on New Managed Property



5. Enter the Property Name and add the crawled properties that you want to add by clicking on the Add mappings button.


6. Click OK.

Once you have created the new custom managed property, go to the Advanced Search page.
1. Click on Site Settings and then on "Edit Page"
2. Click on Edit Menu of the Webpart and then Select "Modify Shared Web part"
In the Advanced Search Box Pane, click on the Properties Menu and then select the content in the Properties Text Box. In order that your Managed Properties appears in the Properties lists, you need to make changes in the XML file content.



The XML File in Properties has the following structure:
  • Find the string:
  • <PropertyDef Name="ModifiedBy" DataType="text"
    DisplayName="Last Modified By"/>
  • Add the following String below it:
    <PropertyDef Name="MyProperty" DataType="text" DisplayName="MyProperty"/>
  • MyProperty denotes the managed property that was created in Search Settings in the Shared Services.
  • Find the ResultType node:
    <ResultType DisplayName="All Results" Name="default">
  • Add the following string below this:
    <PropertyRef Name="MyProperty" />
  • Now you can click on Apply and OK to close the pane.

The property "MyProperty" will appear in the Property list box when All Results is selected.