Professional Documents
Culture Documents
This document is provided “as-is”. Information and views expressed in this document, including URL and
other Internet Web site references, may change without notice. You bear the risk of using it.
Some examples depicted herein are provided for illustration only and are fictitious. No real association or
connection is intended or should be inferred.
This document does not provide you with any legal rights to any intellectual property in any Microsoft
product. You may copy and use this document for your internal, reference purposes.
Microsoft, SharePoint, Visual Studio, InfoPath, and Visio are trademarks of the Microsoft group of
companies. All other trademarks are property of their respective owners.
Page 1
SharePoint 2010 Developer Walkthroughs
Contents
Exercise 1 – Web Part and Linq Walkthrough ....................................................................................................... 4
Task 1 - Create a new SharePoint Project ........................................................................................................ 4
Task 2 - Generate LINQ-to-SharePoint proxy class to access list data ............................................................ 7
Task 3 - Access the SharePoint list data in Visual Web Part ............................................................................ 9
Task 4 – Build and Deploy the Visual Web Part .............................................................................................. 11
Exercise 2 – Build a BCS External Content Type ................................................................................................ 16
Task 1 – Create a Business Data Catalog Model project ................................................................................ 16
Task 2 – Update the Schema of the Entity Class ............................................................................................ 18
Task 3 – Update the Service Code .................................................................................................................. 28
Task 4 – Build and Deploy ............................................................................................................................... 30
Exercise 3 – Create a Silverlight Application for the SharePoint Client Object Model ........................................ 34
Task 1 – Create a Silverlight Application Project ............................................................................................. 34
Task 2 – Write code to access and render SharePoint List Data .................................................................... 36
Task 3 – Deploy and Test using the SharePoint Silverlight web part .............................................................. 40
Exercise 4 – Creating a graph using the SharePoint Object Model and Silverlight Graphing controls ............... 42
Task 1 – Create a Silverlight Application Project ............................................................................................. 42
Task 2 – Write code to access Employee SharePoint List Data and display it in a Silverlight Graph Control 46
Task 3 – Deploy and Test using the SharePoint Silverlight Charting web part ............................................... 49
Exercise 5 – Create a Web Part for a Sandboxed Solution ................................................................................. 53
Task 1 – Create a Sandboxed Solution Project with a web part ..................................................................... 53
Task 2 – Add code to provide querying and rendering functionality ................................................................ 55
Task 3 – Build and Deploy the Sandboxed Solution ....................................................................................... 58
Exercise 6 – Creating an Activity for use in a SharePoint Designer Workflow .................................................... 63
Task 1: Create and Prepare Project ................................................................................................................ 63
Task 2: Create a new Workflow Activity for use by the Reusable Workflow ................................................... 64
Task 3: Add code to create a document library based on parameters passed to our activity. ........................ 66
Task 4: Configure activity for deployment. ....................................................................................................... 69
Task 5: Add the SPDActivityDemo activity to be deployed with SPCHOL305Ex1. ......................................... 73
Task 6: Configure a Feature using Feature Designer ..................................................................................... 74
Task 7: Add and code a Feature Receiver ...................................................................................................... 75
Task 8: Create a re-usable workflow using SharePoint Designer ................................................................... 76
Task 9: Import the reusable workflow into Visual Studio ................................................................................. 84
Task 10: Associate the workflow with a list in SharePoint ............................................................................... 91
Walkthrough Summary ......................................................................................................................................... 93
Page 2
SharePoint 2010 Developer Walkthroughs
The following six walkthroughs are C# walkthroughs of select scenarios that professional developers
would do in SharePoint 2010 with Visual Studio 2010.
You should find there are sufficient screenshots in these walkthroughs to read the document without
having hands on access to the software. These developer walkthroughs are also available as hands on
labs as part of this online eLearning course: http://MSSharePointDeveloper.com. There are additional
labs in the course, there are also videos, code samples and online virtual lab environments, and the
hands on labs are available in both C# and VB.NET.
Page 3
SharePoint 2010 Developer Walkthroughs
In this task, a solution and project will be created. It will contain the rest of the development work in
Exercise 1 of this lab.
1. Open Visual Studio 2010 by going to Start Menu | All Programs | Microsoft Visual Studio
2010 | Microsoft Visual Studio 2010.
2. From the menu, select File | New | Project.
3. In the New Project dialog window, choose Visual C# | SharePoint | 2010 from the Installed
Templates.
4. Select Visual Web Part from the Project Items.
Page 4
SharePoint 2010 Developer Walkthroughs
10. Visual Studio will create the new SPCHOL200-Ex1 project and add the necessary files.
Page 5
SharePoint 2010 Developer Walkthroughs
11. Notice that Visual Studio also creates a Visual Web Part named VisualWebPart1. Within the
Solution Explorer, expand VisualWebPart1 and open VisualWebPart1.webpart.
12. Change the value of the property element with the name attribute value of Title to
SPLinqDemoTitle and the value of the property element with the name attribute value of
Description to SPLinqDemoPart Description. This will change the Title and Description property
of the Visual Web Part once it is deployed. Save the file.
<properties>
<property name="Title" type="string">SPLinqDemoTitle</property>
<property name="Description" type="string">SPLinqDemoPart Description</property>
</properties>
Page 6
SharePoint 2010 Developer Walkthroughs
In this task, you will use the new spmetal.exe code generation utility and generate the Linq-to-
SharePoint proxy code.
1. In the Solution Explorer, right-click on SPCHOL200-Ex1 and select Open Folder in Windows
Explorer.
2. Hold Shift key and right click anywhere in the Explorer Window and select Open Command
Window Here to open the command prompt window in the current project directory:
3. Type the following command in the command prompt and press Enter to set the path to the
SharePoint 2010 folder:
set path=%path%;c:\program files\common files\microsoft shared\web server
extensions\14\bin
4. Type the following command in the command prompt and press Enter to generate the Linq-to-
SharePoint proxy code.
spmetal.exe /web:http://intranet.contoso.com /namespace:SPCHOL200_Ex1.VisualWebPart1
/code:SPLinq.cs
Note – you may get warnings about content types for list Form Templates. You can safely
ignore this warning and continue
5. Close the command window and switch back to Visual Studio.
6. In Visual Studio, right click on SPCHOL200-Ex1 project and select Add | Existing Item.
Page 7
SharePoint 2010 Developer Walkthroughs
7. Select SPLinq.cs from the Add Existing Item dialog window and click Add:
8. In the Solution Explorer, right click on References and select Add Reference.
9. Switch to Browse tab and enter C:\Program Files\Common Files\Microsoft Shared\Web
Server Extensions\14\ISAPI in the File Name text box. Press Enter to change directories. Your
Add Reference window should now look like Fig. 11.
10. Select Microsoft.SharePoint.Linq.dll.
Page 8
SharePoint 2010 Developer Walkthroughs
In this task, you will add code to your solution that will allow the Visual Web Part to retrieve SharePoint
list data.
Page 9
SharePoint 2010 Developer Walkthroughs
using Microsoft.SharePoint.Linq;
using Microsoft.SharePoint;
using System.Linq;
spGridView.DataSource = empQuery;
spGridView.DataBind();
Code Snippet: My Code Snippets | spchol200_ex1_pageload
1. In the Solution Explorer, right click on SPCHOL200-Ex1 and select Deploy. This will build and
deploy the Visual Web Part to the local SharePoint site: http://intranet.contoso.com
Page 11
SharePoint 2010 Developer Walkthroughs
5. Switch to Insert tab in the Ribbon and click on Web Part to insert a Web Part to the page.
Page 12
SharePoint 2010 Developer Walkthroughs
Put your cursor in the area of the page where you want the Web Part to appear. This must be a
zone that accepts Web Parts. In this case, put your cursor in the zone below the Shared
Page 13
SharePoint 2010 Developer Walkthroughs
Documents control.
8. Click Add to add the web part to the page. This will add the SPLinqDemoTitle web part to the
selected layout zone.
Page 14
SharePoint 2010 Developer Walkthroughs
9. Click on Page, click the down arrow on the “Save and Close” button, and select Stop Editing
to save the page and stop editing. Click Yes when prompted to save the changes you made.
Page 15
SharePoint 2010 Developer Walkthroughs
1. Open Visual Studio 2010 by going to Start Menu | All Programs | Microsoft Visual Studio
2010 | Microsoft Visual Studio 2010, and from the menu select File | New | Project.
2. Select the Visual C# | SharePoint | 2010 | Business Data Connectivity Model project
template.
3. Enter BDCEx1 in the Name textbox.
Page 16
SharePoint 2010 Developer Walkthroughs
8. Click Finish.
Page 17
SharePoint 2010 Developer Walkthroughs
1. From the top menu, select View | Solution Explorer. In the Solution Explorer, rename
Entity1.cs to Customer.cs and Entity1Service.cs to CustomerService.cs. Click Yes when
prompted with the below:
2. If it’s not already open, double-click on Customer.cs in the Solution Explorer. Replace the code
in the body of the Customer class with the following code. This is adding two extra properties
and changing the type of a third as a mapping for the type descriptors we added and modified in
the BDC definition.
Note when you change the Identifier1 to CustomerId, you can use the glyph that appears in the
editor to rename all references to the field Identifier1. This doesn’t help you in this case but is a
good practice.
Page 18
SharePoint 2010 Developer Walkthroughs
Task 3 – Extend the BCS Metadata for the External Content Type
1. In the Solution Explorer, open the BdcModel1.bdcm if the BDC designer isn’t already open.
3. Rename the Entity1 to Customer by clicking on the Entity1 name in the designer and pressing
F2 (alternatively you can change the name in the Property Grid).
4. Highlight Identifier1 in the Entity designer and press F4 to open the Properties Grid. Use the
Properties Grid to rename Identifier1 to CustomerId and set its Type Name to System.Int32.
Page 19
SharePoint 2010 Developer Walkthroughs
5. In the BDC Explorer in Visual Studio, expand Model | BDCModel1 | BDCModel1 | Customer |
ReadList | returnParameter. Click Entity1List to open its Property Grid.
Page 20
SharePoint 2010 Developer Walkthroughs
9. In the BDC Explorer right-click Customer and select Add Type Descriptor.
10. Select TypeDescriptor and, using the Properties grid, change Name to FirstName.
11. In the BDC Explorer right-click Customer and select Add Type Descriptor.
12. Select TypeDescriptor and, using the Properties grid, change Name to LastName.
Figure 27 - Customer entity in BDC Explorer after the addition of FirstName and LastName type descriptors
14. In the BDC Explorer expand the ReadItem method, right-click returnParameter and select
Paste.
Page 22
SharePoint 2010 Developer Walkthroughs
16. Expand returnParameter | Customer and confirm FirstName and LastName type descriptors
have successfully copied.
Page 23
SharePoint 2010 Developer Walkthroughs
Page 24
SharePoint 2010 Developer Walkthroughs
17. In the BDC Explorer expand the ReadItem | id and select Identifier1.
18. Using the Properties grid, rename Identifier1 to CustomerId, set the TypeName to
System.Int32.
19. Using the BDC Method Details pane add an update method
Page 25
SharePoint 2010 Developer Walkthroughs
Page 26
SharePoint 2010 Developer Walkthroughs
21. Open the new Update method in the BDC Explorer window
22. Copy the type descriptor from the CustomerId type description from @id parameter in the
ReadItem method to the @id parameter in the Update method
23. Change the Pre-Updater property on the id parameter to be True.
Page 27
SharePoint 2010 Developer Walkthroughs
Page 28
SharePoint 2010 Developer Walkthroughs
3. In the Solution Explorer, expand the Features folder and double click the Feature1.feature node.
This opens the feature designer.
4. Click the Manifest tab at the bottom of the feature designer.
5. Click the + glyph next to Edit Options to open the template editor.
6. Add a new Property for the Site URL
Page 29
SharePoint 2010 Developer Walkthroughs
4. Click on Create.
Page 30
SharePoint 2010 Developer Walkthroughs
Page 31
SharePoint 2010 Developer Walkthroughs
Page 32
SharePoint 2010 Developer Walkthroughs
8. Click Create.
9. You have just created an external content type and a list to host that content type.
Page 33
SharePoint 2010 Developer Walkthroughs
1. Open Visual Studio 2010 from Start | All Programs | Microsoft Visual Studio 2010 | Microsoft
Visual Studio 2010.
2. From the menu, select File | New | Project.
3. In the New Project dialog box, expand the Installed Templates left hand menu to Other Project
Types | Visual Studio Solutions | Blank Solution.
4. Select .NET Framework 3.5
5. Name the solution Begin.
6. Enter C:\SPHOLS\SPCHOL306\CS\Ex1\ in the Location textbox.
7. Press OK to continue.
8. From the menu, select File | Add | New Project.
Page 34
SharePoint 2010 Developer Walkthroughs
9. In the New Project dialog box, expand the Installed Templates left hand menu to Visual C# |
Silverlight, and choose the Silverlight Application project type in the project type list in the middle
section of the screen.
10. Select .NET Framework 3.5
11. Name the project SPSilverlightExample.
12. Leave the location unchanged.
15. Within the SPSilverlightExample project we will now add the reference assemblies to the
SharePoint Silverlight Client Object Model. Right-click References in the SPSilverlightExample
project and select Add References.
16. Browse to the “C:\Program Files\Common Files\Microsoft Shared\Web Server
Extensions\14\TEMPLATE\LAYOUTS\ClientBin” folder.
17. Select Microsoft.SharePoint.ClientSilverlight.dll and
Microsoft.SharePoint.Client.Silverlight.Runtime.dll (hold CTRL to select multiple files)
18. Press OK to add the select dll references.
Page 36
SharePoint 2010 Developer Walkthroughs
3. Expand the DataGrid to take up the entire page by going to the properties grid and setting its
Width and Height property to Auto, its HoriztonalAlignment and VerticalAlignment properties to
Stretch, and its Margin to 0..
4. Also make sure to check AutoGenerateColumns (or set its value to true in the XAML).
5. Open App.xaml.cs and add the following using statements to the top of the file:
using Microsoft.SharePoint.Client;
using System.Threading;
ApplicationContext.Init(e.InitParams, SynchronizationContext.Current);
using Microsoft.SharePoint.Client;
Page 38
SharePoint 2010 Developer Walkthroughs
query.ViewXml = camlQueryXml;
_projects = Projects.GetItems(query);
context.Load(_projects);
context.ExecuteQueryAsync(new
ClientRequestSucceededEventHandler(OnRequestSucceeded), null);
Page 39
SharePoint 2010 Developer Walkthroughs
Task 3 – Deploy and Test using the SharePoint Silverlight web part
To deploy the solution to SharePoint the resulting .xap file created by the Silverlight project needs to be
in the C:\Program Files\Common Files\Microsoft Shared\Web Server
Extensions\14\TEMPLATE\LAYOUTS\ClientBin folder.
1. Right-click the SPSilverlightExample project, select properties and select the Build tab.
2. Change the output path to C:\Program Files\Common Files\Microsoft Shared\Web Server
Extensions\14\TEMPLATE\LAYOUTS\ClientBin.
3. Build the solution. The .xap file has been copied to the required SharePoint directory and you are
ready to add the Silverlight web part to the SharePoint website.
4. Open Internet Explorer and browse to http://intranet.contoso.com.
5. Select the Edit icon at the top of the page.
6. Select the Insert tab and the click Web Part.
7. From the Category list select Media and Content, choose the Silverlight Web Part from the
web part list, and click Add.
8. In the Silverlight Web Part dialog that pops up enter
/_layouts/ClientBin/SPSilverlightExample.xap as the URL.
Page 40
SharePoint 2010 Developer Walkthroughs
In this exercise you have created a basic Silverlight application that displays a SharePoint list inside a
datagrid. The data for the list is retrieved from the server so it is available in Silverlight using the
SharePoint Client Object Model.
Page 41
SharePoint 2010 Developer Walkthroughs
In exercise two we will again be using the SharePoint Object Model to access SharePoint list data but
this time we will use LINQ and the Silverlight Charting controls to display the data in a graph.
1. Open Visual Studio 2010 from Start | All Programs | Microsoft Visual Studio 2010 | Microsoft
Visual Studio 2010.
2. From the menu, select File | New | Project.
3. In the New Project dialog box, expand the Installed Templates left hand menu to Other Project
Types | Visual Studio Solutions | Blank Solution.
4. Name the solution Begin.
5. Change the location to C:\SPHOLS\SPCHOL306\CS\Ex2\
6. Press OK to continue.
7. From the menu, select File | Add | New Project.
Page 42
SharePoint 2010 Developer Walkthroughs
8. In the New Project dialog box, expand the Installed Templates left hand menu to Visual C# |
Silverlight, and choose the Silverlight Application project type in the project type list in the middle
section of the screen.
9. Name the project SilverlightEmployeeContributionsGraph.
10. Leave the location unchanged.
Page 43
SharePoint 2010 Developer Walkthroughs
Page 44
SharePoint 2010 Developer Walkthroughs
12. Add a reference to the Silverlight Charting Controls assembly. It is available on the .NET tab
and is called the System.Windows.Controls.DataVisualization.Toolkit.
Page 45
SharePoint 2010 Developer Walkthroughs
Task 2 – Write code to access Employee SharePoint List Data and display it in a Silverlight
Graph Control
1. In the Solution Explorer right-click on the App.xaml file and select View Code. In the open
App.xaml.cs and add the following using statements to the top of the file:
using Microsoft.SharePoint.Client;
using System.Threading;
ApplicationContext.Init(e.InitParams, SynchronizationContext.Current);
xmlns:chartingToolkit="clr-
namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Wind
ows.Controls.DataVisualization.Toolkit"
4. Add the following Silverlight Charting control inside the Grid element:
Page 46
SharePoint 2010 Developer Walkthroughs
5. Open MainPage.xaml.cs and add the following using statement to the top of the file:
using Microsoft.SharePoint.Client;
Page 47
SharePoint 2010 Developer Walkthroughs
query.ViewXml = camlQueryXml;
_employees = employees.GetItems(query);
context.Load(_employees);
context.ExecuteQueryAsync(new
ClientRequestSucceededEventHandler(OnRequestSucceeded), null);
// use linq to group employees on team name and then total team
contributions
List<TeamContributions> teams = employees
.GroupBy(e => e.TeamName)
.Select(t => new TeamContributions
{
Name = t.Key,
Contributions = t.Sum(e => e.Contributions)
}).ToList();
10. Like the previous exercise the SharePoint Silverlight client object model is used to retrieve data
from a SharePoint list. Once the employee contribution items have been populated into a list,
LINQ is then used to group employees into teams and their contributions summed together.
Team contributions are then set as the chart’s data source.
Task 3 – Deploy and Test using the SharePoint Silverlight Charting web part
To deploy the solution to SharePoint the resulting .xap file created by the Silverlight project needs to be
in the C:\Program Files\Common Files\Microsoft Shared\Web Server
Extensions\14\TEMPLATE\LAYOUTS\ClientBin folder.
3. Build the solution. The .xap file has been copied to the required SharePoint directory and you are
ready to add the Silverlight web part to the SharePoint website.
4. Open Internet Explorer and browse to http://intranet.contoso.com.
Page 49
SharePoint 2010 Developer Walkthroughs
5. We will update the Silverlight web part added in the previous exercise to point toward the new
Silverlight Charting control we have just made. Click the dropdown icon in the top right hand
corner of the Silverlight web part and select Edit Web Part.
6. Click the Configure button (you may have to scroll the window to the right to see the Configure
button) and then enter /_layouts/ClientBin/SilverlightEmployeeContributionsGraph.xap in
the Silverlight Web Part dialog.
Page 50
SharePoint 2010 Developer Walkthroughs
7. Click OK.
8. Click OK at the bottom of the Silverlight Web Part sidebar.
Page 51
SharePoint 2010 Developer Walkthroughs
Page 52
SharePoint 2010 Developer Walkthroughs
1. Open Visual Studio 2010 from Start | All Programs | Microsoft Visual Studio 2010 | Microsoft
Visual Studio 2010.
2. From the menu, select File | New | Project.
3. In the New Project dialog box, expand the Installed Templates left-hand menu to Visual C# |
SharePoint | 2010 | Empty SharePoint Project.
4. Name the project SBSolutionDemo.
5. Change the location to C:\SPHOLS\SPCHOL307\CS\Ex1\
Page 53
SharePoint 2010 Developer Walkthroughs
6. Press OK to continue.
7. In the SharePoint Customization Dialog, change the local site to use for debugging to
http://intranet.contoso.com/.
8. Leave the trust level for the SharePoint solution as Deploy as a sandboxed solution.
9. Press Finish to continue. Visual Studio will create the new project and add the necessary files.
10. Right-click on the SBSolutionDemo project in the Solution Explorer and select Add | New item.
11. Ensure Visual C# | SharePoint | 2010 | is selected in the Installed Templates pane.
12. In the Add New Item dialog, select to add a new Web Part and name it SBWebPart.
Page 54
SharePoint 2010 Developer Walkthroughs
1. Open SBWebPart.cs and add the following using statement after the other using statements:
using System.Web.UI.HtmlControls;
Page 55
SharePoint 2010 Developer Walkthroughs
Page 56
SharePoint 2010 Developer Walkthroughs
Page 57
SharePoint 2010 Developer Walkthroughs
1. Right-click the SBSolutionDemo project and select the Package to create a .wsp file.
2. Open Internet Explorer and browse to http://intranet.contoso.com.
3. Open the Site Actions menu and select Site Settings.
4. Under the Galleries section select Solutions.
Page 58
SharePoint 2010 Developer Walkthroughs
Page 59
SharePoint 2010 Developer Walkthroughs
Figure 67 - SBWebPart
Page 60
SharePoint 2010 Developer Walkthroughs
18. Select System Account in the toolbar at the top right hand side of the page and choose Sign in
as Different User.
19. For the User name enter andyj and for the password enter pass@word1.
Page 61
SharePoint 2010 Developer Walkthroughs
Page 62
SharePoint 2010 Developer Walkthroughs
In this task a project you will create an Empty Project solution and use SharePoint user controls.
1. Open Visual Studio 2010 by going to Start | All Programs | Microsoft Visual Studio 2010 |
Microsoft Visual Studio 2010.
2. In Visual Studio 2010, create a new project by going to File | New | Project.
3. Select the Visual C# | SharePoint | 2010 | Empty SharePoint Project project template.
4. Enter SPCHOL305Ex1 in the Name textbox, and enter C:\SPHOLS\SPCHOL305\CS\Ex1 in the
Location textbox.
5. Click OK.
6. In the SharePoint Customization Wizard, change the URL to http://intranet.contoso.com and
select Deploy as a farm solution. Then click Finish.
Page 63
SharePoint 2010 Developer Walkthroughs
7. Visual Studio will create the new SPCHOL305Ex1 project and add the necessary files.
Task 2: Create a new Workflow Activity for use by the Reusable Workflow
1. In Visual Studio 2010, add a new project by going to File | Add | New Project.
Page 64
SharePoint 2010 Developer Walkthroughs
5. In Solution Explorer, right-click the SPDActivityDemo project and select Add Reference.
6. Switch to the Browse tab. Enter C:\Program Files\Common Files\Microsoft Shared\Web Server
Extensions\14\ISAPI in the File name textbox and hit Enter.
7. Select Microsoft.SharePoint.dll and Microsoft.SharePoint.WorkflowActions.dll, and click OK.
Page 65
SharePoint 2010 Developer Walkthroughs
Task 3: Add code to create a document library based on parameters passed to our activity.
1. Right-click on the CreateDocumentLibrary.cs file in the Solution Explorer and select View
Code.
2. Change the CreateDocumentLibrary base class from SequenceActivity to Activity, as seen
below.
3. Add the following using statements at the top of the file under the existing using statements.:
Page 66
SharePoint 2010 Developer Walkthroughs
using Microsoft.SharePoint;
using Microsoft.SharePoint.Workflow;
using Microsoft.SharePoint.WorkflowActions;
Page 67
SharePoint 2010 Developer Walkthroughs
Page 68
SharePoint 2010 Developer Walkthroughs
1. Configure activity for a strong name. Add SPDActivityDemo.snk from Resources folder.
(Location at the start of this manual). To the SPDActivityDemo project.
2. Right-click on the SPDActivityDemo project in the Solution Explorer and select Properties.
3. Click on the Signing tab, check “Sign the Assembly, and then select SPDActivityDemo.snk.
Figure 76 - Signing
Page 69
SharePoint 2010 Developer Walkthroughs
5. Right-click on the SPCHOL305Ex1 project and click Add, SharePoint Mapped Folder
6. Select Template\1033\Workflow in the Add SharePoint Mapped Folder dialog and select OK.
Page 70
SharePoint 2010 Developer Walkthroughs
Page 71
SharePoint 2010 Developer Walkthroughs
Page 72
SharePoint 2010 Developer Walkthroughs
1. In the Solution Explorer expand the Package folder under the SPCHOL305Ex1 project.
2. Double-click on the Package.package file to bring up the Package designer.
3. Click on the Advanced tab on the bottom of the designer
Page 73
SharePoint 2010 Developer Walkthroughs
4. Click the Add button and select Add Assembly from Project Output.
5. In the Add Existing Assembly from Project Output dialog click the Source Project combo
and select SPDActivityDemo\bin.
6. Click the button under Safe Controls. Within Safe Controls add the following:
Assembly Name:
SPDActivityDemo, Version=1.0.0.0, Culture=neutral, PublicKeyToken= a66e91d2ee2fa8f8
Name Space: SPDActivityDemo
Safe: Checked
Type Name: *
7. When you have finished filling out the safe control details, press Enter to confirm them.
8. Click OK
1. Right-click on the Features folder in the Solution Explorer under the SPCHOL305Ex1 project
and select Add Feature.
Page 74
SharePoint 2010 Developer Walkthroughs
1. Right-click on the SPCHOL305Ex1Feature feature in the Solution Explorer and select Add
Event Receiver
2. Add a using statement to the top of the code:
using Microsoft.SharePoint.Administration;
Page 75
SharePoint 2010 Developer Walkthroughs
4. Build and Deploy the SPCHOL305Ex1Feature project by Right-clicking on the project name
and selecting Deploy.
1. Open SharePoint Designer 2010 by going to Start | All Programs | SharePoint | Microsoft
SharePoint Designer 2010
Page 76
SharePoint 2010 Developer Walkthroughs
Page 77
SharePoint 2010 Developer Walkthroughs
Page 78
SharePoint 2010 Developer Walkthroughs
5. Click the Reusable Workflow button and when prompted name the workflow SPDWorkflow
and then click the OK button to create the reusable workflow.
Page 79
SharePoint 2010 Developer Walkthroughs
6. Click the Actions button in the ribbon and scroll down to Labs and click Create a Document
Library. Note: This is the activity we made in Visual Studio previously.
Page 80
SharePoint 2010 Developer Walkthroughs
7. Click into Step 1. In the box next to Document Library Name click the Fx button.
8. Select Current Item as the Data Source, and Title as the value of Field from source. Then
Press OK.
Page 81
SharePoint 2010 Developer Walkthroughs
11. Once saved click the Publish button in the ribbon. Wait for the workflow to publish.
Page 82
SharePoint 2010 Developer Walkthroughs
15. Click Site Actions -> View All Site Content -> Site Assets Library.
16. Click on the SPDWorkflow dropdown menu and click Send To -> Download a Copy.
Page 83
SharePoint 2010 Developer Walkthroughs
17. Save the WSP to a location that you can access in a subsequent step (like the Desktop)
1. Back in Visual Studio 2010, right-click on the SPCHOL305Ex1 solution in the Solution
Explorer window Add | New Project.
2. Select the Visual C# | SharePoint | 2010 | Import Reusable Workflow project template.
Page 84
SharePoint 2010 Developer Walkthroughs
4. Click Ok.
Page 85
SharePoint 2010 Developer Walkthroughs
Page 86
SharePoint 2010 Developer Walkthroughs
6. When prompted for the .WSP file to import, browse to the SPDWorkflow.wsp file you saved
previously. Click Next.
7. Click Finish.
Page 87
SharePoint 2010 Developer Walkthroughs
Page 88
SharePoint 2010 Developer Walkthroughs
8. Double-click on Package in the SPCHOL305Ex1 project and add the Converted workflows
feature to the Package.
Page 89
SharePoint 2010 Developer Walkthroughs
14. Save the project, build the solution and deploy the SPCHOL305Ex1 project.
Page 90
SharePoint 2010 Developer Walkthroughs
1. Browse to http://intranet.contoso.com.
2. Click on Site Actions | More Options
3. Select Custom List from the items list.
4. Name the list Customers and press Create.
5. Open List Settings
Page 91
SharePoint 2010 Developer Walkthroughs
8. Click OK
9. Navigate to the Customers list and select Items | New Item.
Page 92
SharePoint 2010 Developer Walkthroughs
10. Enter Northwind as name of the new customer and press Save when the Customers – New
Item dialog appears.
11. Wait while a new document library of the same name should be created automatically.
Walkthrough Summary
In this walkthrough document you reviewed walking through six developer scenarios for SharePoint
2010. You can get the hands on labs that these walkthroughs were based on from
http://MSSharePointDeveloper.com
Page 93