Title: Beyond Web Parts: Rapid Web Application Development Using Windows SharePoint Services 3'0
1Beyond Web Parts Rapid Web Application
Development using Windows SharePoint Services 3.0
Nadeem Mitha, MCTS (WSS App Dev) Infusion
Development nmitha_at_infusiondev.com http//home.inf
usionblogs.com/nmitha
2Overview
- The advantages of leveraging SharePoint lists
- The approach at a high level
- The basics (no code required)
- Rolling up sleeves (some code required)
- Common reusable customizations
- Application-specific custom tailoring
- Options for reporting
3Why Build Your Web Application on Windows
SharePoint Services?
4Why Build Your Web App on WSS?
- Common answer WSS lets you integrate document
libraries, discussions and other SharePoint
entities into your web application - In other words, applications built on SharePoint
are for collaboration.
5Why Build Your Web App on WSS?
- We can leverage more from WSS. Think Lists
- User-manageable content types
- Provide Create, Retrieve, Update and Delete
(CRUD) functionality and search w/o code - Security model and auditing w/o code
- Inheritance, item-level ACLs, security groups
with ability to designate owners, draft item
security, limit user to modifying only items they
create
6Why Build Your Web App on WSS?
- Lists offer even more
- Web services and RSS w/o code
- Recovery support via recycle bin w/o code
- Content approval, version history, alert
notifications and workflow w/o code - Support for creating and saving personal views
w/o code - Integration with Excel w/o code
7Common Developer Myths about Customizing
SharePoint
8Myths
- Myth 1 Customizing SharePoint amounts to writing
custom web parts - Myth 2 Its hard to force SharePoint do anything
differently, or do something it cant do OOTB
9The Approach
10The Approach
- Define entities as content types
- Entity properties site columns
- Relate entities via lookup columns
- Attach content types to lists, enable and
leverage desired list features - Write or reuse customizations that provide base
functionality and glue
11The Approach
- Use event receivers, workflows, custom context
menu actions or web parts as a means to kick off
custom code for business logic - Use the Object Model to make things happen in
SharePoint
12SharePoint 2003? forget about it
13WSS 2.0 Wont Work
- WSS 2.0 event receiver framework is too
inadequate - WSS 2.0 has no OOTB workflow support
- WSS 2.0 does not employ content types
- WSS 2.0 does not support multi-valued lookup
columns
14The BasicsWhat You Can Do Before You Need
Custom Code
15The Basics
- Use OOTB content type and list functionality
- Define an entity definition as a content type
- Use OOTB field types to create columns for each
attribute/property of the entity - Wide selection for basic column types
- Add any calculated columns you might need
- Use inheritance, have a base content type
16Defining an entity using a content type and OOTB
field types
17The Basics
- Introduce lookup columns to relate entities
- Real world data has relationships with other data
- WSS 3.0 (SharePoint 2007) now allows multiple
values to be assigned to a single lookup field - Allows many-to-many relationships
- Myth Lookup columns only work for lists on the
same site (SPWeb) - Not true create the lookup column on the site
containing the list, then use the column in any
sub-site of that site
18Relating entities using lookup columns
19The Basics
- Count Related feature of the lookup column
- Column value will display the number of items in
another list that link to the current item - Example
- List of Status Reports
- Each Status Report linked to a Project using
lookup - Each Project can show of associated Status
Reports when you define a lookup column on
Projects (into Status Reports) has a display
field with the text (Count Related) selected
20The Basics
- Content types can be packaged for reuse and
deployment by using the feature framework - Well-documented
- Can define your content type in the UI and
extract the XML markup (CAML) for creating the
feature
21Time to go beyond OOTB
22Advanced Columns and Custom Field Types
- Computed columns
- Render HTML based on CAML markup
- Three deployment options Object Model
(AddFieldAsXml), web services or feature
framework - Good for generating hyperlinks to actions or
related content - Tip Computed field can use count related field
to create link to view showing related entities
23Computed column
24Advanced Columns and Custom Field Types
- Custom field types
- Well-documented
- Validation is straightforward (override
GetValidatedString method and throw
SPFieldValidationException when value is invalid) - Facilitated by Visual Studio template
- Can override controls for editing, rendering
field and defining column - Last is free if you have only simple custom
properties
25Common Reusable Customizations
26Cross-Listing DataImplementing Two-Way
Bidirectional Lookups
- Scenario
- Several Technologies are associated with any
given Project - Each Technology item should list all associated
Projects that use (are associated with) that
Technology - This makes it easy to filter the Technologies
list to show only those Technologies associated
with a particular Project (similar to a simple
join)
27Cross-Listing DataImplementing Two-Way
Bidirectional Lookups
- Implementation
- Use the event receiver framework to capture
ItemAdding and ItemUpdating events on the
Projects list - Procedure for creating and registering event
receivers is well-documented - Can use a tool such as SharePoint Inspector to
bind your event receivers (find using Google)
28Cross-Listing DataImplementing Two-Way
Bidirectional Lookups
- Implementation (continued)
- The back reference column on the Technology
content type can be hidden on just the new and
edit forms and still visible on the display form - Method 1 Edit fields CAML (OM, web services or
in feature definition) - Method 2 Use tool such as SharePoint Tips
Utility Pack (find on Google)
29Cross-listing data (bidirectional lookup)
30Site ProvisioningCreating SharePoint Sites
Linked to New List Items
- Scenario
- New Project item is created
- Each Project can (or must) have its own
associated SharePoint site - Think Document Workspace, but for list items
- Implementation
- Kick off OM code to create site using event
receiver, or using context menu action on list
item
31Site ProvisioningCreating SharePoint Sites
Linked to New List Items
- Implementation (continued)
- Site can carry reference to the associated list
item by storing list item ID or title in site
property bag - Can allow unpriveleged users to create these
sites using SPSecurity.RunWithElevatedPriveleges - Note must use context URLs to instantiate new
SPWeb object in the elevated code method since
any existing SPWeb (e.g., from context) will
carry over users restricted permissions
32Creating site linked to new list item
33List View Filtered by ContextDisplaying View of
List in a Sub-Site, Specific to the Sites
Associated List Item
- Scenario
- Homepage of Project site must show list of all
Technologies associated with the project - The related Technologies list should show
additional properties of each Technology - Method 1 Page Viewer
- Page Viewer to show list, querystring to filter
- Custom aspx to show list without chrome (Google
PrintList.aspx
34List View Filtered by ContextDisplaying View of
List in a Sub-Site, Specific to the Sites
Associated List Item
- Method 2 Remote List View Web Part
- Custom or third party web part
- Free implementation at KWizCom.com
- Can code connections support, or build filtering
into web part - List viewer looks at property bag for filtering
data - Method 3 Data View Web Part
- Well-documented
- No need to unghost (can export/import web part)
35List View Filtered by Context
36Populating Form Values by ContextPre-Selecting
Values in New Forms Based on Where New was
Clicked
- Scenario
- List of Technologies on your Project homepage has
an Add New Technology link at the bottom - User expects added technology to be associated
with current project - Implementation
- Add querystring parameter to the Add New
hyperlink - AssociatedProjectltThe Project Namegt
37Populating Form Values by ContextPre-Selecting
Values in New Forms Based on Where New was
Clicked
- Implementation (continued)
- Use JavaScript on NewForm.aspx to select the
appropriate project based on the querystring
parameter - One option for adding JavaScript is to add custom
web part to NewForm.aspx (or content editor web
part) - Append ToolPaneView2 querystring parameter
- Other options for adding JavaScript master page,
custom.js
38Pre-selected value in New Form based on context
39Application-Specific Custom Tailoring
40Customizing the List Item Context Menu
- Appears when the drop-down arrow in the Title
field is clicked - Easiest use is to redirect user to an aspx page
while passing the list item ID as a parameter - Example CreateSite.aspx?AssociatedItemId3
- JavaScript-based. Google CAMOpt and look at
CORE.js for examples. - Local or global change possible
41Customizing the OOTB New/Edit Forms
- Create and use custom field types
- Edit or replace NewForm.aspx and/or EditForm.aspx
- Change on a per list basis using ToolPaneView2
- Can use OM to switch these pages at a content
type level - Fields can be modified to be hidden from New or
Edit forms as necessary
42Reporting
43Customizing the OOTB New/Edit Forms
- Could be a lengthy presentation on its own
- For now, just know that you have several options
- Option 1 OOTB Access or Excel integration (pivot
tables, etc) - Option 2 Create usable views of list data in
SQL, then use with SQL Reporting Services,
Crystal Reports, etc (contact me for C script) - Option 3 Third-party solution
44Questions?
Nadeem Mitha, MCTS (WSS App Dev) Infusion
Development nmitha_at_infusiondev.com http//home.inf
usionblogs.com/nmitha