After migrating to new SharePoint farm strange Firewall error started showing up for Micrsoft WorkSpace

Recently after migrating to new SharePoint farm, Microsoft WorkSpace started showing up strange error

“SharePoint Workspace is unable to communicate through your firewall and will run with limited functionality. To resolve this problem, enable SharePoint Workspace as a Windows Firewall exception…”

Following is the error dialoge in Swedish language.
Workspace screen shot

Solution: Just installed SharePoint Workspace 2010 hotfix on the client machines and it got fixed.

faisal 😉


New stuff for SharePoint Development in Visual Studio 2012

This blog I am going to write about new stuff that has been introduced in MS Visual Studio 2012 for SharePoint development. The over all color theme of MS Visual Studio 2012 is quite different than as it was in MS Visual Studio 2010.

Here is the description of some new features introduced in Visual Studio 2012 for SharePoint development.

Reorganised the SharePoint Project Templates
The SharePoint project templates and project item templates have changed. Some SharePoint project templates from the previous version of Visual Studio were moved into project item templates.

As previously in Visual Studio 2010 many developers have been using Empty SharePoint Project instead of using Event Reciever, List Definition, Content Type, Module project types etc, So now in Visual Studio 2012 these project types have been moved to project items. SharePoint Project templates provided in Visual Studio 2012.
Visual Studio 2013 New SharePoint Project

SharePoint Project templates provided in Visual Studio 2010
Visual Studio 2010 New SharePoint Projects Types

The SharePoint project artifacts that cannot not be used for sand-box solutions has description “Farm solution only”. An new project item “Silverlight Web Part” is also available that is a actually a solution with web part project along with a Silverlight project.

SharePoint Project item templates provided in Visual Studio 2012
Visual Studio 2013 New SharePoint Project Items

SharePoint Project item templates provided in Visual Studio 2010
Visual Studio 2010 New SharePoint Project Items

Create Site Columns, Content Types and Lists by Using New Designers
When you create a new list or content type or list column in Visual Studio, a designer now helps you set up and lay out the contents of the new list or content type. The designers enable you to display, sort, and group the available site columns.

Publish SharePoint Solutions to Remote SharePoint Servers
In addition to deploying SharePoint solutions to a local SharePoint site, you can now publish SharePoint solutions to remote SharePoint sites.

You can use this feature as shown below. click right click project and select “Publish”

Publishing item in Solution Menu

Enter the URL of remote SharePoint site and click publish.

Publish command

Log on to the remote server if user authentication is required. The publishing progress appears in the Visual Studio Output window. When the process is finished, the solution (.wsp) file is installed on the remote SharePoint server. However, it must still be activated before it can be used in SharePoint.
On the Solution Gallery page, select the SharePoint application and then on the ribbon, choose the Activate button. In the Activate Solution dialog box, on the ribbon, choose the Activate button again. The Status column on the Solution Gallery page indicates that the application is active.

Test SharePoint Performance by Using Profiling Tools
The Visual Studio SharePoint tools now provide full support for performance profiling. The profiling tools help you identify code and other elements in your SharePoint projects that slow down and adversely affect the performance of your SharePoint applications.

In current example I am going to analyse “CPU Sampling” of current project. The sampling profiling method collects statistical data about the work that is performed by an application during a profiling run.

To do so please follow the following steps. Open and deploy your solution.

1. In Visual Studio 2012, on the Analyze menu, choose Launch Performance WizardCapture

2. On page one of the Performance Wizard, leave the method of profiling as CPU sampling and choose the Next button.On page two of the Performance Wizard, leave the profile target as project name and choose the Next button.

Performace Wizard 1

3. If a solution has multiple projects, they appear in this list.Performace Wizard 2

4. On page three of the Performance Wizard, it displays “Tier Interaction Profiling (TIP)”, If you suspect database related performance issues, make sure you will use the tier interaction option “Tier Interaction Profiling (TIP)”. This will reveal the issued SQL-Statements during profiling.The Tier Interaction Profiling (TIP) feature is useful for measuring the performance of applications that query databases and for showing you the number of times a web page is requested. Performace Wizard 3

5. On page four of the Performance Wizard, leave the Launch profiling after the wizard finishes check box selected, and then choose the Finish button.

Performace Wizard 4

The wizard enables application profiling on the server, displays the Performance Explorer window, and then builds, deploys, and runs the SharePoint application.

Now in SharePoint site browse through and invoke the functionality that you are investigating about performance issues and then close the SharePoint site. Now that you have run and profiled the SharePoint application, view the test results.

In the Functions Doing the Most Individual Work section of the Sample Profiling Report. You will find the the biggest performance bottlenecks in the application.

Profiling Report

Improved Support for Sandboxed Solutions.
Visual web parts now support sandboxed SharePoint projects, not just farm projects. When working on sandboxed solutions, Visual Studio displays a compiler error if you attempt to use farm-only API calls. Also, Visual Studio IntelliSense displays only APIs that are compatible with sandboxed solutions when you are working in a sandboxed solution.

Sand Box Solution

Support for JavaScript Debugging and IntelliSense for JavaScript
You can now debug JavaScript in SharePoint projects, and IntelliSense is provided when coding JavaScript in SharePoint projects. URL resolution for JavaScript is enabled for visual web parts in sandboxed solutions. This means that you can reference JavaScript files located in SharePoint’s content database in your SharePoint projects in Visual Studio. The code is automatically included at build time.

For more details:

Creating auto-increment field in SharePoint List

In SharePoint, we can create the auto-incremental field by many ways, I am going to discuss two ways of doing it.

  1. Calculated field
  2. Item Event Receiver

1. Using Calculated field:

Using this we can accomplish it without doing any programing and it is a relatively simple way of doing it. By using “Calculated” column in SharePoint List we can create auto-increment field. We can accomplish this by creating a new column and choosing the column type as “Calculated (calculation based on other columns)”. And in Formula field, we have to enter [ID]

In fact this will be using the values from “ID” field from SharePoint list that starts from 1.

For example, if we want to start our auto-increment column from 100, we can modify the “Formula” field of Create New column screen, we can have to enter [ID] + 99

Auto-Increment field using Calculated column in SharePoint List

2. Using Item Event Receiver:

By using this strategy, users have advantage to edit the existing values, we can also avoid it by making field read-only on feature activation. Using item event receiver, on ItemAdded event, we have to find the highest value among previously added items and then save the incremented value to current newly created auto-incremental column.

In code given below, its looks up for the highest value in the existing items, and adding the incremented value to the newly added item.

    public override void ItemAdded(SPItemEventProperties properties)
            SPWeb web = properties.OpenWeb();
            bool allowUpdates = web.AllowUnsafeUpdates; //store original value
            this.EventFiringEnabled = false;

                web.AllowUnsafeUpdates = true;
                /*get the current list*/
                SPList list = web.Lists[properties.ListId];
                var highestvalue = 0;
                var objQuery = new SPQuery
                                       Query ="<OrderBy><FieldRef Name='" + ColumnName 
                                       +"' Ascending='False' /></OrderBy><RowLimit>1</RowLimit>",
                                       Folder = list.RootFolder

                SPListItemCollection colItems = list.GetItems(objQuery);
                if (colItems.Count > 0)
                    highestvalue = int.Parse(colItems[0][ColumnName].ToString());

                var currItem = properties.ListItem;
                currItem[ColumnName] = highestvalue + 1;
            catch (Exception ex)
                this.EventFiringEnabled = true;
                web.AllowUnsafeUpdates = allowUpdates; //restore original value

Happy Coding 😉