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);
docSet.Item.SystemUpdate(false);


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);

                        try
                        {

                            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;
                                        break;
                                    }
                                }

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

                                    _TermStore.CommitAll();
                                }

                            }
                            else
                            {

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

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

                                _TermStore.CommitAll();

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

                }
            }

For any queries, please write to me.