Thursday, February 28, 2013

SharePoint 2010: Documents not routing in Drop Off Library

Drop Off Library, one of the very useful feature of SharePoint 2010 is very helpful when you have thousands of documents and you have to sort them out or redirect them to their owners or route them to their respective libraries. As you know that we need to activate the Content Organizer at out site level to use drop off libraries. Sometimes, the documents you send to the drop off libraries and not routed instantly in-spite of the fact that the rule you mentioned in the Content Organizer Rules is matching the documents. If this is your scenario, please try the following to get your routing started.

  • Make sure all the required fields for the content type you are routing has valid values in them
  • If you want to manually run the Content Organizer Processing job(in Central Admin), it will start the routing process and will route the documents instantly. This job is scheduled to run daily by default. Whenever this job runs and it cannot route the documents in the drop off library, it will send an email to the Rule manager stating the reason and some instructions.

Wednesday, February 20, 2013

SharePoint 2010 : Content types that are available to this Document Set have been added or removed. Update the Document Set.

Sometimes when we click on a document set and within the same we see a yellow line reading 
Content types that are available to this Document Set have been added or removed. Update the Document Set.
The reason behind it is that this document set is not created using the OOB way but using some kind of code practices. Ideal way to create document set is by using 

- DocumentSet.CreateDocumentSet

which sets the docset_LastRefresh property. But doing it in any other way doesn't set this property resulting in the above warning message. To get over with this, we should manually write the code to set the property and prevent seeing this warning in every document set created this way.

SPFolder docSet = web.GetFolder("site/doc lib/folder");
docSet.Item.Properties["docset_LastRefresh"] = SPUtility.CreateISO8601DateTimeFromSystemDateTime(DateTime.UtcNow);

Tuesday, February 12, 2013

Inserting Terms to the Term Store : SharePoint 2010

Managed Metadata, one of my most widely used feature in SharePoint 2010 comes with many exciting things. I tend to use them very often depending on the business case. Recently I came across a scenario where I had to Insert almost 1000 items to the Term Store with their sub sets. In my case it was the list of manufacturers and their products. So I wrote a console application to do the same. In my case, I had a excel sheet of values which I read using my previously created ReadExcel.cs. Here is the code :

 using (SPSite site = new SPSite(""))
                TaxonomySession _TaxonomySession = new TaxonomySession(site);

                //Get instance of the Term Store
                TermStore _TermStore = _TaxonomySession.TermStores[""];

                //Instance of Term Store
                Group _Group = _TermStore.Groups[""];

                //Instance of Term Group
                TermSet _TermSet = _Group.TermSets[""];

                FileStream filename = File.Open(@"", FileMode.Open);

                for (int i = 1; i <= 1000; i++)

                   // ReadExcel.ReadxlswithID() is my function to read the row values in Excel

                    if (ReadExcel.ReadxlswithID(filename, "A" + i.ToString(), "Sheet2") != null)
                        string manufacturer = ReadExcel.ReadxlswithID(filename, "A" + i.ToString(), "Sheet2");

                        string product = ReadExcel.ReadxlswithID(filename, "B" + i.ToString(), "Sheet2");

                        TermCollection terms = _TermSet.GetTerms(manufacturer, true);


                            if (terms.Count > 0)
                                Term tExists = _TermSet.GetTerm(terms[0].Id);
                                //Get the branch of terms within terms
                                TermCollection subTermExists = tExists.GetTerms(50);

                                bool termAlreadyExists = false;

                                for (int j = 0; j < subTermExists.Count; j++)
                                    if (product == subTermExists[j].Name)
                                        termAlreadyExists = true;

                                if (e == false)
                                    Term subTerm = tExists.CreateTerm(product, 1033);



                                Term _term = _TermSet.CreateTerm(manufacturer, 1033);

                                Term _sTerm = _term.CreateTerm(product, 1033);


                        catch (Exception ex)
                            Console.WriteLine(ex.ToString() + product);


For any queries, please write to me.

Monday, February 11, 2013

The search request was unable to connect to the Search Service : SharePoint 2010

Its a monday morning and we ran into a issue where the search wasnt working. The error message I was getting was 

The search request was unable to connect to the Search Service

I followed the following options to resolve the error. Hope you will find your solution within them.

  • Central Admin > Application Management > Manage Web Application > select your SharePoint site > Service Connections
    • Check whether the Search Service Proxy is checked or not, if not please tick the same and save. This will resolver your issue.

  • Central Admin > General Application Settings >  Farm Search Administration > click on your search service 
    • Under Search Application Topology on the bottom of the page, make sure the status for all the categories is ONLINE. My problem was that the Query Component 0 was saying "Not Responding" which was running on my Web Front End Server. So I logged in to my WFE and followed the following steps to resolve the issue :
      • Go to Services.msc and make sure SharePoint Server Search 14 service is Running

Issue Resolved !!  Hope this helps someone.

Friday, February 8, 2013

SharePoint 2010 : Copying Document sets programatically from one library to another with metadata

Many of you must have come across situations where you have to move the already created Document sets (with a whole bunch of documents in it) from one location to another due to organization re-structure or may be introduction of some new ways of working.
I did come across similar situation where I had to move 5000 Document Sets with documents in them counting 60,000 in total from one library to another. In my case the document sets are within a folder in the source library. Since I am not a folder-loving developer, I tend not to use them frequently.

So here is my code to copy the document sets from source library and put it into the destination library without folders.
Please note:

  • Metadata columns (for Document Set and Document) should read same in the destination library and the source library if you want them to be copied along the process
  • Make sure you have set up Document Set content types in the destination library
I am using a console application so add reference to  
  • Microsoft.SharePoint
  • Microsoft.Office.DocumentManagement.DocumentSets
and make sure your target machine and build is set to proper values.

using (SPSite site = new SPSite("http://sharepointsite"))
                using (SPWeb web = site.OpenWeb())
                    SPFolder folder = web.GetFolder("folderURL"); // sharepointsite/library/folder

                    SPList sourceList = web.Lists["sourcelistname"];

                    SPQuery query = new SPQuery();                    
                    query.Folder = folder;

                    SPListItemCollection itemColl = sourceList.GetItems(query);
                    foreach (SPListItem sourceItem in itemColl)

                        if (sourceItem.ContentType.Name == "Document Set")
                            DocumentSet documentSet = DocumentSet.GetDocumentSet(sourceItem.Folder);

                            SPList targetList = web.Lists["targetListName"];

                            SPContentTypeId contentTypeId = targetList.ContentTypes["destination document library"].Id;

                            byte[] documentSetData = documentSet.Export();

                            string documentSetName = documentSet.Item.Name;

                            SPFolder targetFolder = targetList.RootFolder;

                            Hashtable properties = sourceItem.Properties;

                            DocumentSet.Import(documentSetData, documentSetName, targetFolder, contentTypeId, properties, web.CurrentUser);

SharePoint 2010 : No available sandboxed code execution server could be found

This might cause your sand boxed cause to seize and not perform their regular functions.

You need to re-start(Stop and Start again) the Microsoft SharePoint Foundation Sand boxed Code Service from services on server. You might see that it is already started, still just Stop the service and Start again.

Central Administration > System Settings > Servers > Manage Services on server > Start the Microsoft SharePoint Foundation Sand boxed Code Service

Try this at first instance which might resolve your error. If this doesn't work, you can email me and we can work it out together.