Showing posts with label sp2010. Show all posts
Showing posts with label sp2010. Show all posts

Monday, March 11, 2013

SharePoint2010 : Calculated Columns


SharePoint calculated columns often become very useful while doing simple or I should say not so complex calculations within SharePoint fields. I have had requirements which are not an easy one and not even so complex that I should be writing some kind of custom code to implement them, where I find the use of SharePoint calculated columns very useful. While implementing the calculations, I browsed many books, blogs and MSDN forums and found the below mentioned link very useful.


I am sure this post will encourage you more to use SharePoint calculated columns where ever required as they are easy to implement and no maintenance required. 

Happy SharePointing !!

SharePoint2010 : Creating Surveys


Creating surveys and recording response in SharePoint is a very useful feature of any intranet or internet facing site. Surveys can be recorded periodically every quarter or monthly based on organizations. This blog post shows how to create a survey and record responses from the audiences. 
  • You must log on to your SharePoint site with admin rights.
  • Click on View All Site Content and click on Create 
  • Select Lists from the left and select Surveys from the list
  • Enter the name of your survey and click on Create.



Now that our list is created, it’s time to enter the questions for the survey. 
  • Enter your question and click on Next Question until you finish entering all your questions one by one. While filling in the questions, you can select the field type for each question and proceed. You can also branch your users according to their responses, how to do that, we will see later in this post.


Now that you have finished entering all your questions, you should click on Finish which will take you to the list settings page where you can see all your questions listed. Now, you can click on the question you want to put branching on and enter the branching criteria. Finally when all this is done, you are good to test your survey. Click on the survey list from the left hand navigation which will take you to the survey list. Click on Respond to survey for filling in the answer to the questions and submit your survey. Now, if you want the audiences to have only the survey submission rights and they should not be able to view what others are submitting, restrict access to the library accordingly.

Hope this helps

Friday, March 8, 2013

SharePoint2010 : Setting Content Organizer Rules within Record Center


Setting rules within the Content Organizer is required to route your documents to send to their destination library. For the interim period they can sit within the Drop Off library, and based on the rules we set, they are routed to their destination library. As we activate Content Organizer within our site, the Drop Off library is created by default. This post describes how we can set the rules to route our documents which we send to Record center.

  • Go to Site Settings > Content Organizer Rules under Site Administration.
  • Click on Add Item.


  • Fill in the name for the rule.
  • Select the Rule Status and Priority
  • Select the Content Type (make sure you have added this content type to your destination library)
  • Most importantly, select the condition on which the routing should occur next.
  • Finally, select the Target library clicking on the browse button.
There you go, the rules are set now. You are good to send documents to your Record Center which will come to its Drop Off library and then routed to your destination library.

Thursday, March 7, 2013

SharePoint2010 : Introduction to Record Center

The Records Center is intended to serve as a central repository in which an organization can store and manage all of its records. The Records Center supports the entire records management process, from records collection through records management to records disposition.

When we are implementing Document Management within our organization, and we have thousands of documents to maintain within a library whereas many of them are historic, and we do not use them very often, it makes sense to keep them separate and not clog your library with huge number of items. Hence, SharePoint gives us the flexibility for document retention using Record center. We can create record center and send our documents to it once they are approved and are in their final version. Sending to Record center can be of three types mainly: 
  • Copy the document to Record Center 
  • Move the document to Record Center
  • Move to the document to Record Center and Leave a link
As per the business case, we can implement any of the above mentioned way to treat our items within the library. 

Steps to implement Document Management through Record center: 

SharePoint2010 : Create Record Center


Creating Record Center is very simple. It is just created like any other team site within SharePoint. 
  • Go to All site Content. Click Create 
  • Select Site > Record Center
  • Enter the desired display name and the URL for the record center
  • Click on Create


There you go!! The Record center is created and ready to use.
You might notice the Drop Off Library is listed on the left hand navigation which is a part of Content Organizer is activated by default. 

This is the temporary placeholder library where all the items when sent to the Record center using Send To connection are stored. We will have to set rules to this library to move our items to their destination library within the Record Center.

Wednesday, March 6, 2013

Applying Retention Policy to SharePoint 2010

Records Management is one of the very important aspects of SharePoint 2010 along with document management. Retention can be set either on content types or on folders depending on business case. In this post, I will explain how to set retention on any SharePoint library.
To start with applying retention to your library items, let us create a content type and then we will apply the retention to the content type which will drive the documents throughout their life cycle.
Now that we have our content type ready, document is in the library with valid value in the metadata field, we can proceed to apply retention to the content type.

Step 1: Click on Library Settings > Information management policy settings (under Permissions and Management)
Step 2: You can see the Vouchers content type listed along with the by default Folder content type. Click on Vouchers content type.

Step 3: Check the Enable Retention check box and click on Add a retention stage
Step 4: To trigger off the retention, our custom column (Voucher Date) which we added while creating the content type will be listed here. Select Voucher Date from dropdown and put 2 years (for the sake of this post). This is where you will put in your business case and fill in the value you want.
Step 5: Once we selected the Voucher Date and entered the number of years, now it’s time to select the kind of action we would want to perform on the item. The Action dropdown will list the available actions to choose from.

Let us declare the item as record after 2 years (for sake of this post).
Select Declare Record and click on OK.
Now you will be directed to the previous page with your event described as below. If you want you can add another stage of retention based on your organisation policy. For example, you would want to delete the item after keeping it for another 5 years after you have declared as a record. So you can add another stage here. Also, you may want to send the record to Record Centre after certain period, you can add that here by adding a new stage.
And we are done. We have now successfully applied retention to our content type.
You can follow the similar way to apply retention to any folder; the process is exactly the same, so I am not mentioning it in my post.

The SharePoint job which works in background to make the retention work is Information management policy job and Expiration policy job. They can be scheduled as per your organization policy going into the Central Administration > Monitoring > Review job definitions (under Timer jobs).


Create Custom Content Type in SharePoint 2010

Content Management is an integral part of SharePoint 2010. It helps organize your documents, items and records in a way you have control over its life cycle. We can define what fields we want to use in content types and their data types. Also we can apply validations on the fields within a content type. This blog post describes creation of a custom content type within the site collection and using it within the document library.
Step 1: Create a content type “Vouchers” with some metadata columns.
Go to Site Settings > Site Content Types (under Galleries) > Create.

Step 2: Create two additional columns within the content type.


Step 3: Create a document library named “Payment Vouchers”.


Step 4: Enable use of Content types within the library.
Go to Library Settings > Advanced Settings (Under General Settings) and select Yes for Content Types.

Step 5: Add our custom content type to this library.
Click on Add from existing site content types and select our newly created content type “Vouchers” from the list and click Add. Also, I will remove the Document content type available in this library by default to avoid any confusion.

Once we add the Vouchers content type and remove the Document content type, the New Item ribbon button in our library will look like below:

Step 6: Now we can upload some documents to this library.
Click on Upload Documents and browse your file to upload. Once the upload is done, you will be asked to fill in the metadata for our content type Vouchers.

If you note, we made Voucher Date as mandatory, which is marked as a red asterisk. After filling in proper metadata, click on Save to complete the upload. Content types can be very helpful when you have thousands of documents in the same library and you have many types of documents in it, so creating separate content types for them and saving them under their appropriate values with their respective metadata values can be very helpful within the organization. Also, content types are very useful when you have a similar kind of documents within your site in different libraries, so you can create a content type and re use it in all the libraries. Implementation of Retention schedules also is one key benefit of using own custom content types.

Tuesday, March 5, 2013

SharePoint 2010 : Query using SPMetal entity

In SharePoint 2010, we can use LINQ queries to search data within SharePoint site. In previous SharePoint versions, I tend to use CAML queries instead, which is an efficient way to look for items. However, LINQ queries are faster and simpler to implement.
For more information on LINQ queries: follow this URL
For using LINQ within SharePoint, Microsoft has provided a tool named SPMetal.exe which resides in the 14 hive folder. This tool generates an entity class which we can add to our Visual Studio solution to get intellisense and use the entity classes for fetching data from SharePoint site.

Using SPMetal.exe

Go to command prompt and navigate to
  • C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\bin
  • Type SPMetal.exe /web:http://sharepointsite /code:C:\MyLINQEntity.cs

Now if you open the file, we just created, you can see all the lists, libraries have their classes with content types mentioned. It might happen that some custom content types are replaces with Item which is by default behaviour; you can modify the content types for the actual ones (you will get it in the intellisense).

Now that you add your .cs file to your Visual Studio project, you can use it for fetching items in SharePoint site.

using (PropertiesEntityDataContext context = new PropertiesEntityDataContext(SPSiteAddress))
{
//creating object from the Entity
EntityList<legalcasedocumentset> documentSet = context.GetList<legalcasedocumentset>(libName);
var first3Items = from item in documentSet.ScopeToFolder(folderURL, true)
where item.Name == docSetName
select item;

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 &lt;= 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 &gt; 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 &lt; 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.

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.


Saturday, July 21, 2012

SharePoint 2010 Content Management

Enterprise Content Management(ECM) combines the traditional content management, social capabilities, and powerful search, it is as natural to manage as it is to use. With its simple, “behind-the-scenes” administration, we can configure the content management to our use.

I would like to explain some of the aspects of Content Management in this article.

As we come across managing the content within an organization, we deal with metadata which is the data about data. MOSS 2007 has site columns as metadata which were very useful in organizing and searching data. SP2010 comes up with more such ease of managing your data and meta with concepts with content organiser, in place record management, document id and so on.

Let take Document ID feature first, so in SP2010 whenever any document is uploaded, it is assigned a unique Document ID which remains with the document throughout its life cycle irrespective of which library/site it is in. This makes documents easily searchable and more manageable. With the document ID,we can search it and locate its current position. Its always good to have one unique field associated with our content and this time SharePoint gives it to you by default.

SP2010 makes the use of managed metadata which was there in MOSS2007 but in a very efficient way. For that we first need to understand the concept of Term Store. A term store is a collection of Term Sets which is again a collection of Terms. Now terms are the tags which we define in central admin which can be used across our site collection level or web application level. We need to create a set of terms and name them according to our line of business (LOB). The set of these term sets are called term store. Now lets go to our document library settings and try adding a new field as managed metadata, it will bring you with the option to select yours tags, which are same as what we just defined in central admin now as term sets. We can select single or multiple tags as per the requirement. This makes our content easily manageable and fast searchable.

So we see that managed metadata connects our term sets and the content.

Another new feature In Place Record Management is another important feature by which we can declare a content as Record and it will behave in a specific way we assign. For that we have to initially configure how we want the records to behave and then declare the content (as required) as Record, using an inbuilt ribbon button. This separates that particular content from others and is very useful when we are dealing with archival of documents.

Content Organizer (Metadata driven) can create deep, hierarchical folder structures and manage retention at each folder in the hierarchy(or inherit from parent folder) and route incoming documents to the libraries. So we see that it can act as a post office where all the documents arrive and then routed to their specific houses from there. We can configure our emails to arrive here and based on rules (metadata), we can route our content.