Posts

Showing posts from January, 2012

Find Duplicate Documents in SharePoint 2010 using SPSiteDataQuery

SPSiteDataQuery query = new SPSiteDataQuery();                                             query.Webs = "<Webs Scope='SiteCollection' />"; //query all web sites in site collection                         query.Lists = "<Lists ServerTemplate='101' Hidden='FALSE' MaxListsLimit='0' />";                         query.Query = string.Empty;                         query.Query = "<Where><Eq><FieldRef Name='FileLeafRef' /><Value Type='File'>" +    lblDocumentName.Text + "</Value></Eq></Where>";                         query.ViewFields = _viewFields;                         results = oweb.GetSiteData(query);                                                                                        GrdDuplicates.DataSource = results;                         GrdDuplicates.DataBind();                      

How To: Step by Step Creation of External List in SharePoint 2010

Click Here

Activating and Deactivating Features with PowerShell in SharePoint 2010

Image
Enable-SPFeature –Identity Reporting –url http://sp2010 If your command worked successfully, you will see nothing and just get a blank prompt back. If you would like to get some feedback from the command, you can have it return the SPFeature object back to you by specifying the – PassThru  parameter. We can confirm that the feature did in fact activate successfully using the SharePoint UI. Get-SPFeature However, if you want to know which features are enabled, you can pass it a URL for a given scope (i.e.: –Web, –Site, –WebApplication, and –Farm).  So to get a list of all Site Collection scoped features, we would use the – Site  parameter. Get-SPFeature –Site http://sp2010 You can still specify a specific feature or even use Where-Object to query the list as well. Get-SPFeature –Identity Reporting –Site http://sp2010 Refer : Click Here

Possible values of the Scope attribute for SPSiteDataQuery class

<Webs Scope="Recursive" /> <Webs Scope="SiteCollection" /> When the Scope attribute is set to Recursive, the query considers the current Web site and all subsites of the current Web site. When the Scope attribute is set to SiteCollection, the query considers all Web sites that are in the same site collection as the current Web site. Of the two attribute values, this is the more inclusive.

List out All Views for a SharePoint List

  public void RetrieveViews()         {             try             {                 using (SPSite osite = new SPSite("SiteURL") )                 {                     using (SPWeb oweb = osite.OpenWeb())                     {                         SPList olist = oweb.Lists[ListName];                         if (olist != null)                         {                             SPViewCollection oviewCollection = olist.Views;                             foreach (SPView oview in oviewCollection)                             {                                 ComboBox1.Items.Add(oview.Title);                               }                         }                     }                 }             }             catch (Exception ex)             {                 MessageBox.Show("RetrieveViews() "+ex.Message);             }

Enable Version to SharePoint2010 Library

 public void CheckVersionEnable(string ListName)         {             SPSecurity.RunWithElevatedPrivileges(delegate()             {                 using (SPSite osite = new SPSite("http://URL/"))                 {                     using (SPWeb oweb = osite.OpenWeb("http://URL/"))                     {                         SPList docs = oweb.Lists[ListName];                         if (docs.EnableVersioning == false)                         {                             docs.EnableVersioning = true;                             docs.MajorVersionLimit = 10;                             oweb.AllowUnsafeUpdates = true;                             docs.Update();                             oweb.AllowUnsafeUpdates = false;                         }                     }                 }             });         }

upload a file in sharePoint 2010 document library with the metadata

Click Here

Change the Port Number using PowerShell

Set-SpCentralAdministration -port 1024 iisreset # And use whatever port number you choose #Note: the above command will make changes to IIS as well

Thought of the Day Web Part

Click Here

Retrieving SharePoint Site Information

Click Here

SharePoint 2010 Custom Ribbon Button–Copy Task

Click Here

Send an email with html format using SPUtility.SendEmail

SPWeb oWeb = SPContext.Current.Web StringDictionary headers = new StringDictionary(); headers.Add("from",  " system@domain.com "); headers.Add("to", spUser.Email); headers.Add("subject", "Welcome to the SharePoint group: ABC site: "); headers.Add("content-type", "text/html"); //This is the default type System.Text.StringBuilder strMessage = new System.Text.StringBuilder();                    strMessage.Append("<br><br><b>Login Instructions: </b><br>"); strMessage.Append("<font color='red'><UL><li>If you are a US employee ALWAYS login in using the following login format </font><br>"); SPUtility.SendEmail(web, headers,strMessage.ToString());

SharePoint 2010 Ribbon Locations

Click Here