Pages

Subscribe:

Thursday, February 9, 2012

Document ID service in SharePoint 2010

SharePoint 2010 includes a new Site Collection scoped Feature called the Document ID Service.  As most of you might be aware that in a traditional ECM [Enterprise Content Management] application each content object has its own unique ID, which is used by that object throughout its lifetime in the ECM system, no matter where the file was placed in the system. Once enabled all your documents within a Site Collection will have a unique ID and can be located using the ID no matter where the file is located in your Site Collection.
To enable the Document ID Feature
1. Go to Site Settings > Site Collection Features and Activate the Document ID Service.

2. Or you can use the following SharePoint 2010 Management Shell cmdlet to Activate the Document ID Service.
Enable-SPFeature -id docid -url <site collection url>
After Activating the Feature you can find the “Document ID settings” under Site Collection Administration

3. To customize the Document ID and apply Document ID to all existing Documents in the Site Collection. Go to Site Settings > Document ID Settings and provide the String with which the Document ID will begin. I have provided SP2010 for this example. Click Ok.
You might see this message, "Configuration of the Document ID feature is scheduled to be completed by an automated process." as highlighted in the image:
This message is shown because the timer job called Document ID enable/disable job has been activated. 
Run the Document ID assignment job under Central Administration > Monitoring > Review Job Definitions Once the job completes at the scheduled time, the message will go away or else you may run the timer job and put it to completion forcibly by clicking "Run Now". Or you can run the following SharePoint 2010 Management Shell cmdlet to trigger the same.
Start-SPTimerJob -Identity DocIdAssignment


Now if you go to your document properties you should see, it has a new property called Document ID followed by a Unique ID for that document

4. The above document now has a unique ID and we can use the following link to locate the document no matter where the document is in the Site Collection
http://SP2010:1234/_layouts/DocIdRedir.aspx?ID=SP2010-1-1

Wednesday, February 8, 2012

Hide "Recently Modified" From Quick Launch in SharePoint 2010



The “Recently Modified” on the Quick Launch is enabled by default. If you’re dealing with only a few pages and don’t want to mess with SharePoint Designer, here’s a quick solution to remove the “Recently Modified” link in SharePoint 2010.

1. Type in the CSS code below into Notepad. Save the file as a text file.
2. <style>
     .s4-recentchanges
      {
          DISPLAY:none;
      }
   </style>

3. Upload to file to your SharePoint site. Copy the link to the file by right clicking on the filename       then clicking on “Copy Shortcut”.
4. Go to Edit mode of the page where you want the “Recently Modified” link to disappear.
5. Add a Content Editor webpart (under Media and Content) on the page.
6. Edit the webpart.
7. In the Content Link box, paste the URL you copied in 2) above.
8. Under Appearance, choose “None” as the chrome type.
9. Click OK.

Friday, February 3, 2012

SPLongOperation - SharePoint Processing Page

I have used this class on various occasions when needing to programmatically create sites and modify properties to various object.  In the following example I have a custom Web Part that has a button on it to create a site where I need perform some custom actions.

As a SharePoint Developer, you can wrap your lengthy operations code with the SPLongOperation to display the spinning wheel processing screen whenever you are executing long duration code-block to improve the user experience. After invoking SPLongOperation object, you can start and stop the long operation using Begin() and End() methods. Alternatively, you can use the LeadingHTML and TrainingHTML properties to customize the message on the processing screen.
protected void btnProvisionSites_Click(object sender, EventArgs e)
{
    //Long Operation Code
    using (SPLongOperation longOperation = new SPLongOperation(this.Page))
    {
        //Custom Messages on the Spinning Wheel Screen
        longOperation.LeadingHTML = "Provisioning Sites";
        longOperation.TrailingHTML = "Please wait while the sites are being provisioned.";
        //Start the long operation
        longOperation.Begin();
        //Your Long Operation Code Goes Here...
        // e.g. Site provisioning code
        //End the long operation
        string redirectURL = SPContext.Current.Web.Url;
        longOperation.End(redirectURL);
    }
}
Happy Coding...!!!!

Wednesday, February 1, 2012

SharePoint 2010 List Throttling


SharePoint 2010 has a number of new features centered around working with large lists.  A new feature incorporated into SharePoint 2010 for putting limit on the amount of data to be retrieved from the servers. The feature is called List Throttling.
SP2010 can support up to 50 million items in a list now, but you don’t obviously want to return all of those in a single query.  To aid with this, SP2010 introduces list throttling settings (configured at the web application level), that allow you to specify how many items a user can query before the throttle kicks in and aborts the query.  At the time of writing, these limits are set to 5,000 for normal users and 20,000 for super users.  Remember you can change these settings if you so choose.  I’ll be curious to see what numbers people actually end up running with.  This applies to anything that queries the list whether its through the SharePoint UI or from your own custom code.  If the user submits a query that is too large, the SharePoint UI will tell the user that the query is too big and they need to filter it.
List throttling is managed through web application. Click on Application Management --> Manage Web Applications.  Select the web application you want to configure list throttling, then in the ribbon click on the General Settings drop down and select the Resource Throttling item. Below figure shows how to enable list throttling in a web application.


In order to retrieve information using the object model in order to retrieve up to the number of items specified in the List query size threshold for auditors and administrators property, there is a property you need to set in your query object. 
The property is called QueryThrottleMode and it applies to the SPQuery andSPSiteDataQuery classes.  You simply set this property to override and then use your class instance to query. 
using (SPSite oSite = new SPSite("http://sp2010:1234")) 
{
using (SPWeb oWeb = oSite.RootWeb)
{
SPList oList = oWeb.Lists["Test List"];

SPQuery oQuery = new SPQuery();
oQuery.QueryThrottleMode = SPQueryThrottleOption.Override;


            SPListItemCollection oListColl = oList.GetItems(oQuery);
            //Your custom logic here for processed data
}
}