Friday, May 27, 2011

Content Query WebPart (CQWP) in SharePoint 2010

Content Query WebPart comes first in MOSS 2007, but in SharePoint 2010 there are some new features introduced.Content Query Web Part (CQWP) is used to show information from sites in the current site collection by querying, filtering, and sorting the content. Also CQWP you can show information from list as well as from publishing pages. But to use CQWP publishing features need to be enabled.

To add a content Query Web Part (CQWP) Click on Edit Page -> From Editing Tools Select Insert -> Web Part -> Select Content Roolup Categories and then Select Content Query WebPart.

Wednesday, May 25, 2011

What is Content Organizer in SharePoint 2010?

This helps in managing large libraries. If a user is not sure into which document library or folder they should put a document in that case Content Organizer will be helpful. Content Organizer will look at the new content and checking the document’s metadata against some predefined and prioritized rules, and, if a matching rule is found, saving the content to the document library and folder specified in the rule. It can even manage large libraries by automatically creating new folders if the content in the target folder grows beyond a specified threshold.

To activate the Content Organizer go to Site Actions -> Site Settings In the settings page go to Site Actions and click on Manage Site Features -> then activate the Content Organizer feature. See figure

What is Document Sets and How to create Document Sets in SharePoint 2010?

In this post we will discuss about What is Document Sets and How to create Document Sets in SharePoint 2010?

Also you can check out:

- Difference between site pages and application pages

- SharePoint 2010 List Tutorials

- Get 4 part assembly name of a custom web part in SharePoint 2010

We can create document libraries in SharePoint 2010 to store, maintain versions or to give unique permissions. But a single document does not represent a complete work product sometime. A work product may consist of multiple documents. So we used Folders can be used to group documents; however, folders cannot be versioned or be the target of an event receiver or workflow.

So it comes Document Set:
Document Set enables users to group multiple documents that support a single project or task, together into a single entity. All documents in a Document Set share the metadata and the entire set can also be versioned.

When you access a Document Set you get a web part page that displays the documents like they would be displayed in a document library view. There are also some other features available explained below which I have followed from the Inside SharePoint 2010 book.

Allowed Content Types: 
The types of content that are permitted within the document set.
Shared Fields: Common columns that exist on the document set and child content types. When the value is changed in the document set, SharePoint automatically updates the metadata on all documents in the document set with the new value.

Welcome Page:
SharePoint implements documents sets as a Web Part Page when users view them with a browser. The Welcome page displays specified fields from the document set’s content type, as well as the individual files that make up the document set.

Default Content: 
When users create a new instance of the document set, it can provision new content that is associated with one of the allowed content types automatically.
You can create programmatically like below:
public static void CreateDocumentSetContentType(string libraryUrl)
{
using (SPSite site = new SPSite(libraryUrl))
{
using (SPWeb web = site.OpenWeb())
{
//create the new document set contenttype
SPContentType newDocumentSet = web.ContentTypes.Add (new SPContentType(web.ContentTypes["Document Set"],web.ContentTypes,
“NameOfdocumentSet”));
//get a an instance of DocumentSetTemplate for the new document set
DocumentSetTemplate newDocumentSet = DocumentSetTemplate.GetDocumentSetTemplate(newDocumentSet );
//add allowable content types
newDocumentSet.AllowedContentTypes.Add
(web.ContentTypes["Document"].Id);
//add a shareable property
newDocumentSet.SharedFields.Add(newDocumentSetContentType.Fields["Module"]);
newDocumentSet.Update(true);
newDocumentSet .Update();
web.Update();
}
}
}

Thanks to Abinash and GS TRADEX Team

So finally I got one Header Image for my web site from Abinash and GS Tradex team. Thanks a lot to the whole team. Just to let you know my readers, Abinash and I both studied MCA from CITE and luckily Abinash got lots of oppertunities there in Bhubaneswar and now he is in a very good position at GS Tradex.
As promised through my announcement I will send you a good gift from my side within a week. I also requested to all the superb designers to send me some more logo and also need some feedback for this logo.
Thanks a lot !!!

Wednesday, May 18, 2011

My Announcements

Want to add topic to my web site?
If any one want to add topic to this web site, please mail me (fewlines4biju@gmail.com) your email id. SharePoint professional are highly invited. Once you will send me your email id, I will give you permission to add topics to my website. :) 
Suggestion for Header Image:
I am planning to change my web site's header image which is currently in use. For this I am requesting you to send me some header images. I will use that header image in my web site and the Top 5 senders will get a gift from my side for sure. I can not afford more money, but surly you will like the gift.

Saturday, May 14, 2011

Deploy .wsp file using Visual Studio 2010 for SharePoint 2010 | Deploy webpart to production server using PowerShell in SharePoint

In this post we will discuss how to deploy a .wsp file using browser, PowerShell and STSADM command. This will be very much helpful when you will deploy your webpart to production server.

Also you can check out:
- Deploy SharePoint 2010 solution(.wsp) package using Powershell

- Backup of Site collection in SharePoint 2010

- Enable Sign in as Different User Option in SharePoint 2013

A solution package is a distribution package that delivers your custom SharePoint Server 2010 development work to the Web servers or the application servers in your server farm. Use solutions to package and deploy custom Features, site definitions, templates, layout pages, Web Parts, cascading style sheets, and assemblies.

Wednesday, May 11, 2011

How Indexing process and query process works in Search in SharePoint 2010?

In this post we will discuss how indexing process and query process works in SharePoint 2010 search. Also you can check out my previous posts on:

- Create Search Service Application in SharePoint 2010

- Create an approval workflow in SharePoint Designer 2010

- Call jQuery to SharePoint page using Custom Action

Indexing Process:
The indexing process is responsible for building the index file. The index file contents the properties from the content sources.Content sources can be SharePoint sites, websites, external file systems, Exchange Server public folders, Business Connectivity Services (BCS) External Systems, or other custom repositories. The Index Engine gains access to these repositories through .NET Assembly Connectors and access to the contents of individual items through IFilters.

IFilters are used to allow the indexing process to access the contents of an item. Ex IFilters allow the indexing process to access the body of Microsoft Office documents so that a full-text search can be performed. While SharePoint 2010 ships with IFilters for Office documents, you may need to install additional IFilters for other types, such as PDF documents.

Query Process:
Query execution process begins when a user navigates to the Search Center and enters a query. The query in the Search Center may take the form of a simple keyword or an advanced search with multiple values against multiple Managed Properties.

When the user issues a search, the query is sent to the search engine. Within the search engine, the query processor accepts the query and also retrieves any required information from the Managed Properties database. The combination of the user query and Managed Property information is then sent to the query server, which executes the query and returns the results.

The results are returned as Extensible Markup Language (XML) to the Search Center where they are formatted using Extensible StyleSheet Language for Transformations (XSLT).

Tuesday, May 10, 2011

How to create an application page using Visual Studio 2010 for SharePoint 2010?

An application page is an ASP.NET Web page that is designed for use in a SharePoint Web site. We can attach the master page to an application page so that it will the page will have same appearance and behaviour like other pages. Application pages are shared across all sites on the server, whereas a site page is specific to one site.

Also check out:

- Content Editor Web Part in SharePoint 2010

- AllowUnsafeUpdates in SharePoint 2010

- Approve master page using PowerShell in SharePoint 2010

An application page is the best type of page to create if you want the page to contain custom code.

We can create an application page using visual studio 2010 for our SharePoint site. Please follow the below steps.

Step-1:
First create a Sharepoint 2010 empty project by going to File -> New Project -> then choose Empty Sharepoint Project template, then give a Name and location then click on OK.

Step-2:
Then in SharePoint customization Wizard Choose Local site URL and choose deploy as farm solution.

Step-3:
In this next step: Select the project name in the solution explorer and click on Add new Item then click on Application Page template and give a page name and click on OK. See the figure.


Step-4:
After that you can change the master page by selecting DynamicMasterPageFile="~masterurl/default.master"
and also you can write anything inside the ContentPlaceHolderID.


Step-5:
If you will look at the solution explorer there will be Layouts mapped folders like shown below.


Now you can debug by clicking on F5. Then you can visit the below URL
http://bsahoo3:8787/sites/Training/_Layouts/ApplicationPageTest/MyTestApplicationPage.aspx
Here ApplicationPageTest is the project name. You can check a very good SharePoint 2010 deployment article.

How to create event receivers using Visual Studio 2010 in SharePoint 2010?

In this post we will discuss how to create an event receiver in SharePoint 2010?

Also you can check out:

- How to create an application page using Visual Studio 2010 for SharePoint 2010?

- Content Editor Web Part in SharePoint 2010

- JQuery reference in Application pages in SharePoint

We can create event receivers using Visual Studio 2010 in our SharePoint 2010 site. You can follow the below steps for the same.

Step-1:
Open Visual Studio 2010 -> File -> New Project -> Select SharePoint 2010 under Visual C# section. Then choose Event Receiver project template from the list of templates. Give a name for the project and click ok as shown in the figure below.


Step-2:
Then choose deploy as farm solution and give the URL for debugging in the drop down as shown below then
click on Next.

Step-3:
This step is very much important. Here first choose what type of receiver you want. Here I have added List Item Events.
-->
Then select the event source and Here I have choose custom list.
Then choose what the events and I have selected Item Added and Item Updated Event. After selection the window should be look like the below figure.

Step-4
Now you can write code for the events that you have selected in Step-3. Here I have only add a sample code for a ItemAdding event as below. This will cancel the operation with error message if the particular list title is not "Test".

Here is the code below:

public override void ItemAdding(SPItemEventProperties properties)
       {
           //base.ItemAdding(properties);
           if (properties.ListTitle != "Test")
           {
               properties.Status = SPEventReceiverStatus.CancelWithError;
               properties.ErrorMessage = "You can only add to the Test List !!!";
               properties.Cancel = true;
           }
       }

You can also check how to attach event receiver to SharePoint list.

SharePoint 2010 out of box Search

In this post we will discuss about various types of out of box search in SharePoint 2010. Also you can check my previous posts on:

- Advantages of FAST Search in SharePoint 2010

- Disable default email for approval workflow in SharePoint 2010 designer

- How to make date time picker read-only in InfoPath 2010?

SharePoint 2010 provides 5 different type of out of box search:
1. Microsoft SharePoint Foundation 2010 Search:
This comes with SharePoint foundation 2010. This will work only with one site collection at a time and it cannot index external data sources.

2. Microsoft Search Server Express:
This is an Enterprise Search product that is freely downloadable. This engine can index external sources and supports search federation. It is intended for organizations that want an Enterprise Search capability but do not require significant scalability.

3. Microsoft Search Server 2010:
This is an Enterprise Search engine that can scale across multiple servers and tens of millions of items. This product is the upgraded version of Search Server Express. It is intended for organizations that need a scalable search engine but are not using SharePoint Server 2010.

4. Microsoft SharePoint Server 2010:
This provides all the facility of Search Server 2010 and also provides integration of people search, taxonomy and social networking.

5. FAST Search Server 2010 for SharePoint:
This is the most powerful of all the search offerings. FAST provides scalability beyond any of the other offerings and supports additional customization and configurations. Also you can check advantages of FAST Search in SharePoint 2010

You can also check about Crawler, Indexer and Query in Search, Click here.

Monday, May 9, 2011

How to Create a Content Type using Visual Studio 2010 in SharePoint 2010

In this post we will discuss how to create a Content Type using Visual studio 2010 in SharePoint 2010. Also you can check out:

- How to create event receivers using Visual Studio 2010 in SharePoint 2010?

- Retrieve all web site title and list title in current site collection in SharePoint

- Create user profile synchronization connection in SharePoint 2013

Follow the below Steps:
Step-1:
Open Visual Studio 2010 -> File -> New Project ->Select Content Type project template type -> Then give a name and Location and Solution name. See fig below

Step-2:
Then in the SharePoint Customization Wizard give the local site URL for debugging and then select deploy as farm solution and click on next. See fig below.

Step-3:
Then in this step select a parent content type from which you want to inherit the current content type. Here I have selected the Document content type. Refer figure below.

Step-4:
After step-3, when you open the solution explorer you will see the Elements.xml file where you can change the name, description of the parent content type as seen below in the figure.

Step-5:
Then you can use Field tag to add a field to the content type. For the field ID you can go to Tools->Create GUID and copy the GUID and paste the field’s ID property. Then you can field type to choice as below.

   
      India
      Srilanks
      Pakistan
   
 
If you are using the caml.net.intellisense.vsix file then you need not worry about the intelligence support for the above xml file.

Step-6:
Then refer the above field in the Field Ref attribute in the xml as follows.

     
   
The whole XML file will look like the figure below.

Then Deploy the solution and now we are ready with the content type. To use this we have to do some administration as described below.

Step-7:
Go to Share Documents document library then in the ribbon click on Library -> Library Settings->Advance Settings and select Allow management of content types? To Yes (By default No is selected).

Then scroll down to the Content Types section in the Document Library Settings Page. Then click on Add from existing content types as show in the picture below.

-->
Step-8:
Then in the Add Content Types page Select Custom Content Type in the Select site content types from: dropdown list. Select the Content type and click on Add button and click on OK button as show in the figure.

Then we can use the content type in the Shared Documents document library.

Step-9:
Then go to the Share Document document library then click on Add new item then upload a document and then in the properties page it will show the properties like the figure below.

Hope you will enjoy.

Thursday, May 5, 2011

Exception of type Microsoft.SharePoint.SoapServer.SoapServerExceptio n was thrown

In this post we will discuss how to resolve the error Exception of type Microsoft.SharePoint.SoapServer.SoapServerExceptio n was thrown which comes in SharePoint 2010.

Also you can check my previous posts on:

- KeywordQuery in SharePoint 2010 Search

- New webparts in SharePoint 2013

- How to use log4net in sharepoint 2010?

I got an error while trying to add user to a group in SharePoint 2010.

Web_Reference.UserGroup userGroup = new Web_Reference.UserGroup();

userGroup.Credentials = System.Net.CredentialCache.DefaultCredentials;

userGroup.Url = @"URL Of the Site/_vti_bin/UserGroup.asmx";

string groupName = "Employees";

string userName = "Bijay";

string userLoginName = "Bijay";

string userEmail = "myemail@gmail.com";

string userNotes = "User Added from Client tool";

userGroup.AddUserToGroup(groupName, userName, userLoginName, userEmail, userNotes);
         
//same way you can also remove user from the group by using the following object model.
         
userGroup.RemoveUserFromGroup(groupName, userLoginName);

After executing the error I got the following error

System.Web.Services.Protocols.SoapException: Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerExcepti on' was thrown.

But when I updated the strings to the following format that works for me.

string userName = "Bijay Kumar";
string userLoginName = "domain name/sahoobij";
string userEmail = "myemail@domainname.com";

still I am not sure whther it is the right solution or not but I solved the issue.

Export data from excel sheet in asp.net

Here is the code to export data from excel sheet and put it on dataset in asp.net.

Import this using statements first
using System.Configuration;
using System.Data.OleDb;
using System.Data;

//Retrieve the full path from the FileUpload control
       string filePath = fuPathOfFile.PostedFile.FileName;
        string connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filePath + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=2\"";

        //string connString = ConfigurationManager.ConnectionStrings["xls"].ConnectionString;
        // Create the connection object
        OleDbConnection oledbConn = new OleDbConnection(connString);
        try
        {
            // Open connection
            oledbConn.Open();

Wednesday, May 4, 2011

SAP openings

Here are some openings with my company. Please find the job description below.

Position: Functional consultant - SAP CO
Experience: 2-4 yrs
Location: Pune
Job Description:
Skills -
Should have worked on minimum 1 end to end implementation
Experience on sub modules like CCA, PCA, IO, COPA
Product costing


Position: Functional consultant - SAP SD
Experience: 3-5 yrs
Location: Pune
Job Description:

Openings in Testing

Here are some openings with my company. Please find the job description below.

Position: Sr. Test Engineer
Experience: 3.5 - 5 yrs
Location: Pune
Job Description:
• Skills - Black Box Testing, Clearcase, Clearquest, Dynamic testing, Functional Testing, Integration testing, Load Runner, Load Testing, Manual Testing, Automation Testing, Performance Testing, Quick Test Pro (QTP), JAVA scripting, Regression Test, Static Testing, Stress Testing, White Box Testing, WinRunner, Testing, CMM/CMMI, Problem solving techniques, SDLC Models/Methodologies, ARM,Knowledge Management, Productivity Measurement, Tools and Automation, Linux, Windows XP, MYSQL, Create Test scenarios, strategy, approach, write test cases, Test automation Design & scripts writing, Usage of QTP, domain understanding, testing, create test reports.

Huge openings in Java

Here are some openings with my company. Please find the job description below.

Position: Software Engineer
Experience: 1.5 - 3 yrs
Location: Pune
Job Description:
Skills - J2EE,Java, knowledge of Java Web Server
JAVA J2EE developer, Understanding Customer Requirement
Development, Coding Standards, usage of best practices


Position: Engineer/Sr. Engineer

Experience: 2-5 yrs
Location: Pune
Job Description:
Skills - Eclipse Plugin Development- RCP, JDT,CDT, Java,J2EE

How to Create List and Add Item to that List using SharePoint 2010 client object model?

In this post we will discuss how to create a list and also you can add item to that particular list using SharePoint 2010 client object model.

Also you can check out:

- How to Create a Content Type using Visual Studio 2010 in SharePoint 2010?

- How to create event receivers using Visual Studio 2010 in SharePoint 2010?

- How to hide ribbon in infopath 2010 in SharePoint 2010?

Here is a sample code to create a list and adding an item to that particular list using SharePoint 2010 object model. I have created a windows application and give reference to Microsoft.SharePoint.dll, Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.Runtime.dll. On a button click I am doing the same.

Here is the code sample:
private void btnCreateList_Click(object sender, EventArgs e)
        {
            using (ClientContext context = new ClientContext("http://bsahoo3:8787/sites/Training"))
            {
           
            //Create a new list
            ListCreationInformation listCreationInformation = new ListCreationInformation();
            listCreationInformation.Title = "My Announcements List";
            listCreationInformation.Description += "Here is my list created by client object midel";
            listCreationInformation.TemplateType = (int)ListTemplateType.Announcements;
            listCreationInformation.QuickLaunchOption = Microsoft.SharePoint.Client.QuickLaunchOptions.On;
            List list = context.Web.Lists.Add(listCreationInformation);
            context.ExecuteQuery();

            //Create a new list item
            ListItemCreationInformation listItemCreationInformation = new ListItemCreationInformation();
            ListItem item = list.AddItem(listItemCreationInformation);
            item["Title"] = "First Announcement";
            item.Update();
            context.ExecuteQuery();
            }
        }

How to do exception handling in client object model in SharePoint 2010

In this post we will discuss how to do exception handling in client object model in SharePoint 2010?

Also you can check out:

- How to Create List and Add Item to that List using SharePoint 2010 client object model?

- Implement a breadcrumb into SharePoint 2010 website

- Change column name of list using SharePoint 2013 client object model in autohosted apps

Managed Object Model, Silverlight client object model, JavaScript client object model provide a mechanism for sending error-handling instructions to the server along with the batch operations. The ExceptionHandlingScope object allows you to define a try-catch-finally block that embodies server-side operations. If errors occur during processing on the server, they are handled on the server by the code embodied in ExceptionHandlingScope.

Example:
using (ClientContext context = new ClientContext("URL of the site"))
{
//Set up error handling
ExceptionHandlingScope exceptionScope = new ExceptionHandlingScope(context);
using (exceptionScope.StartScope)
{
using (exceptionScope.StartTry)
{
//Anything you want to do
}
using (exceptionScope.StartCatch)
{
//Fails If any exception occured and you can write code to handle the exception
}
using (exceptionScope.StartFinally)
{
//Try to do anything you want to do in the finally block
}
}
//Execute the entire try-catch as a batch!
context.ExecuteQuery;
}

Here the ExecuteQuery method is called only once, and it will send all the operations defined in the exception handling scope to the server in a single batch.

Also ExceptionHandlingScope class provides different properties like ServerErrorCode, ServerErrorValue, and ServerStackTrace which can be used to analyze the server error and decide about what to do.

Tuesday, May 3, 2011

Finally Sourav Ganguly back to IPL 4

Yes it is TRUE … Sourav Ganguly back to IPL this season finally. Pune warriors took him as a replacement of Ashish Nehera who is injured and is yet to recover. Thanks a lot to one of my dear friend Rohit Sharma who first gave me the news. He got the news from Twitter. And Rohit is always updated.

He will be the vice-captain of Pune for the rest of the matches. Hopefully he will do something special and will prove wrong to everybody who is against him. But he came to a team who has a very less chance to make it to semifinal, already lost 6 out of 8 matches. I think Pune took the decision a bit late, they should bring Ganguly ¾ matches back. Because Pune looks very solid with Ryder, Pandy, Utthapa, Yuvi and Now Ganguly.


He already proved that He is a good 20-20 player with making 450 plus runs last season and more than 1000 runs in the IPL. So I am sure He will his best in the remaining matches for Pune. Now I can support blindly to Pune.

How to use Microsoft Enterprise Library in asp.net for data access?

Microsoft Enterprise Library is a collection of reusable software components used for  logging, validation, data access, exception handling etc used in asp.net.

Here I am describing how to use Microsoft Enterprise Library for data access.
Step 1: First download the project from http://entlib.codeplex.com/ URL.
Step 2: Now extract the project to get

Microsoft.Practices.EnterpriseLibrary.Common.dll
Microsoft.Practices.EnterpriseLibrary.Configuration.Design.dll
Microsoft.Practices.EnterpriseLibrary.Data.dll
Microsoft.Practices.ObjectBuilder.dll

And give reference in the Bin directory by Right click on Bin -> Add Reference -> then give the path of these 4 dlls. Then

Step 3: Modification in the web.config for Connection String.

<add name="Fewlines4bijuConnection" providerName="System.Data.SqlClient" connectionString="Data
Source=BIJAYASQLEXPRESS;Initial Catalog=Fewlines4biju;User ID=sa;Password=bijaya;Min Pool Size=10;Max Pool Size=100;Connect Timeout=100"/>

Monday, May 2, 2011

Lookup column in SharePoint 2010

Look up column in MOSS 2007:
If you want to display List data in a column in a SharePoint List, then we will use Look up column.
There are some disadvantages in MOSS 2007 look up column like: If you delete a value from the list, then any list referred to that element is going to be blank.

2nd is if you can only pick one column to show, If you want to show multiple column you cannot do that. Also if you want to display more information in the look up you cannot do that. So here it come SharePoint 2010 look up column.
SharePoint 2010 Look up column:

In SharePoint 2010 look up column you have the option to show multiple columns as below in the screen shot.