Advertisment

SharePoint 2010 Development & Scripting

author-image
PCQ Bureau
New Update

SharePoint is one of Microsoft's most used server applications. It is used in
Intranets, Extranets and business decision areas and even as a content
management system for many public websites.

Advertisment

SharePoint was available in
different versions — Windows SharePoint Services (WSS) 3.0, Microsoft Office
SharePoint Server (MOSS) 2007 Standard Edition and MOSS 2007 Enterprise Edition.

With the new Office 2010 coming up, SharePoint too gets a new version. WSS
has now been renamed to SharePoint Foundation Services and MOSS remains the
same. There are a huge number of changes in this new version of SharePoint — for
admins, developers and users. We will delve into the changes for developers in
this series. You will need the SharePoint Beta or RC for the code in this
series. These are available for free download from Microsoft's site.

Direct Hit!

Applies To: CIOs, Developers

USP: What's new in upcoming SharePoint 2010 release

Primary Link:
http://sharepoint2010.microsoft.com/


Search Engine Keywords: SharePoint 2010
Advertisment

SharePoint for Developers

One of the pain points of earlier SharePoint development was that you needed
to use Windows Server on each developer's machine to install SharePoint and the
developer tools. One of the coolest new changes for developers in SharePoint
2010 is that these can be now installed on client operating systems such as
Windows Vista and Windows 7. Of course, you cannot run a production site off
these client OSs, but it can really help the developers.

The main development tools for SharePoint 2010 will be Visual Studio 2010 and
SharePoint Designer 2010. Both come with pre-built templates and connections to
SharePoint services that help you build a solution very quickly. We will look
into using these for various tasks throughout this series.

Out of the Box Capabilities

SharePoint 2010 defines the OOB capabilities in the form of the pie displayed.

Advertisment

Sites: allow users to store and retrieve lists and documents along
with tight integration with Office client applications (Word, Excel, etc.).

Communities: allows users to interact with other users by using
features such as search, tagging,  and rating.

Content: managing content on a page, list, records or more.

Advertisment

Search: search content both stored with SharePoint itself or anywhere
else such as enterprise data stores or databases

Insights: ability to digest data in a meaningful form such as
dashboards or KPIs

Composites: extend solutions by business users for their own needs

Advertisment
The SharePoint ecosystem and capabilities matrix.

Each of these can be leveraged by a developer and extended, customized and
solutions created out of them.

Other New Developer Enhancements

SharePoint 2010 has a huge number of other enhancements especially for
developers. The SharePoint SDK has a number of new objects and methods that can
help developers to write code better. SharePoint is based on the .NET Framework
3.5 and not 4.0 and is a 64-bit application.

Advertisment

The UI of SharePoint now contains the ubiquitous Ribbon which is Web based
but works in exactly the same way as in the client applications like Word and
Excel. Developers can extend this ribbon very easily as well.

SharePoint home page after installation.

SharePoint is much more AJAX friendly too now. Most actions result in a
dialog box that refreshes data on the parent without refreshing the entire page
— only the data that changed. This makes for smaller postbacks and faster
rendering. Many dialogs now also support SilverLight based controls making for a
much richer experience than what was available earlier.

Advertisment

Workflows can now be attached to a site rather than a particular list. This
makes for creating reusable workflows much easier and development of these are
very easy. LINQ to SharePoint is another new feature that allows developers to
query lists without resorting to CAML. Developers can use the much more
developer oriented language to query data from within SharePoint.

PowerShell

SharePoint 2010 is also very scriptable using the PowerShell architecture.
Powershell is a great combination of the Windows Command Prompt, UNIX Bash and
an object oriented shell. SharePoint 2010 comes with a built in snap in that
provides access to many of its functions through PowerShell. Let's take a look
at some simple scripting commands that you can perform with SharePoint 2010 on
PowerShell.

Start up PowerShell v2 on a machine that has SharePoint
2010 installed. To use the SharePoint features you need to load the PowerShell
snap-in using this command:

Add-PSSnapin Microsoft.SharePoint.Powershell

Selecting a WebPart adds new contextual tabs to the Ribbon.

To see all the different things that you can do with
Powershell on SharePoint, run the command:

Get-Command -PSSnapin Microsoft.SharePoint.PowerShell

This will show you the whole list of commands you can use
with SharePoint. For instance you can create a new sub web site using the
following command:

New-SPWeb -URL “http://server/Demo01” -Template “STS#0”
-Name “Demo 01” —AddToTopNav —UseParentTopNav

This will create a new site called “Demo 01” on the
SharePoint server and use the STS#0 (Team Web) template. If you wish to delete
the site you can do this:

Remove-SPWeb -Identity “http://server/Demo01” —Confirm:$false

Working with the Object Model

Let's create a simple little project that works with the object model of
SharePoint 2010 in this first part of the series. To do this, open up Visual
Studio 2010 and create a new console application. Make sure it's selected as
.NET Framework 3.5. The first thing to do is to go the properties of the project
and set its build target platform to x64.

A new Task list created and populated through the code.

Once this is done, add a new reference to the
Microsoft.SharePoint and System.Web namespaces. Add a using statement to
reference these on top of the code like this Add the following code to the
application.

static void Main(string<> args)

{

string targetSite = "
http://Win08R2/";

string targetWeb = "Demo01";

using (SPSite siteCollection = new SPSite(targetSite))

{

using (SPWeb site = siteCollection.AllWebs)

{

Console.WriteLine("Creating a new list: My Demo Tasks");

string ListTitle = "My Demo Tasks";

string ListDesc = "Demo Task List created using SP Object Model";

CreateList(site, ListTitle, ListDesc);

Console.WriteLine("Complete");

}

}

}

private static void CreateList(SPWeb site,string ListTitle,string ListDesc)

{

Guid ListID = site.Lists.Add(ListTitle, ListDesc, SPListTemplateType.Tasks);

SPList myTasks = site.Lists;

myTasks.OnQuickLaunch = true;

myTasks.Update();

SPListItem newTask = myTasks.Items.Add();

newTask<"Title"> = "New Task";

newTask<"Assigned To"> = site.CurrentUser;

newTask<"Due Date"> = DateTime.Today;

newTask.Update();

}

This code basically goes ahead and connects to a SharePoint
site and within the web goes and creates a new Task list with a single item
within it. As you can see, the code is fairly simple and self-explanatory.

We've looked at some of the different things that are new
in the upcoming SharePoint 2010 release. We will delve deeper into many of them
as we go further in this series, so keep an eye on this space.

Advertisment

Stay connected with us through our social media channels for the latest updates and news!

Follow us: