SharePoint 2010 Developer Quick Start
Dec 05, 2014
SharePoint 2010 Developer Quick Start
SharePoint Designer Improvements
• Add lists, columns, forms , custom actions without the need to go to the browser.
• Fine grained designer control
• SPD work migrates to Visual Studio 2010– SPD customization work exported to .wsp files– .wsp files imported into Visual Studio
Development lifecycle
Prototype in Designer
Export to WSP
Import to Visual Studio 2010Refine features
Deploy
Demo – Designer
PowerShell
• 2007 administration = STSADM.EXE + extensions and console applications
• Replaced with PowerShell– PowerShell support effectively replaces STSADM.EXE– SharePoint admins/devs must learn PowerShell basics– You can write powerful scripts against WSS OM– You can develop custom PowerShell snap-ins
PowerShell Tools
PowerShell 101
• Get-Command -pssnapin Microsoft.SharePoint.PowerShell
• Get-Help Get-SPSite
• Get-Help Get-SPSite –Examples
• Get-Command -noun "SPService*" | Sort Noun | Select Noun –Unique
• Get-Command -noun "SPService*" | Sort Noun | Select Noun –Unique > text.txt
SharePoint 2010 Developer Dashboard
Correlation ID
Visual Studio 2010 SharePoint Tools• End-to-end SharePoint 2010 developer story
– SharePoint Explorer for site exploration– SharePoint 2010 project and item templates– Visual designers for core scenarios– Migration path for Visual Studio 2008 for WSS 3.0– Extensible by 3rd party developers
• Benefits to SharePoint developers– Abstracts away details of RootFiles directory– Abstracts away details of building .wsp file– Lessens/eliminates need for external utilities
Demo – VS 2010
Feature Improvements
• Feature Versioning & Upgrade (ALM)• New Events• Workflow Association• Property Bag• UI Version• Web Templates• New custom action options
Feature Versioning & Upgrade• Version Range – BeginVersion/EndVersion• Upgrade Elements
– CustomUpgradeAction• Parameters
– ApplyElementManifest– MapFile – FromPath/ToPath– AddContentTypeField
Upgrade Scenario
Site A Feature X 1.0
Deployed
Site B Feature X Not
Deployed
Site A Feature X 1.0
Upgraded
Site B Feature X
Not Deployed
Site A Feature X 1.0
Upgraded
Site B Feature X 1.0 Deployed
+ Upgraded
EventsAdded…• Item Events
– ContextEvent– ItemAdding/ItemAdded– ItemUpdating/ItemUpdated– ItemDeleting/ItemDeleted– ItemCheckingIn/ItemCheckedIn– ItemCheckingOut/ItemCheckedOut– ItemUncheckingOut/ItemUncheckedOut– ItemAttachmentAdding/ItemAttachmentAdded– ItemAttachmentDeleting/ItemAttachmentDeleted– ItemFileMoving/ItemFileMoved– ItemFileConverted
• Workflow Events– WorkflowStarting/WorkflowStarted– WorkflowPostponed– WorkflowCompleted
Site EventsSiteDeleting/SiteDeletedWebDeleting/WebDeletedWebMoving/WebMovedWebAdding/WebProvisioned
List EventsEmailReceivedFieldAdding/FieldAddedFieldUpdating/FieldUpdatedFieldDeleting/FieldDeletedListAdding/ListAddedListDeleting/ListDeleted
Post Synchronous Events
• WSS 3.0 “after” events are exclusively asynchronous
• Problem when wanting to do post processing after item submitted, but before displaying to user
• SPF 4.0 adds new property on receiver definition to change “after” event to synchronous– SPEventReceiverDefinition.Synchronization
Event Impersonation Improvements• WSS 3.0 events run in context of user who
triggered the event• Certain things trigger events to run under
System Account (workflow, etc), but doesn’t permit reverting back to user who triggered action
• SPF 4.0 now adds the originating user & user token on SPEventPropertiesBase
Feature Property Bag• Promote Feature Properties into Web/Site
property bag– Root web– Web– Folder– List Item
• No direct VS designer support• Updates value if exists, otherwise adds
– Types enforced: DateTime, Int32
Web Templates
• Replacement and Improved Framework for STP -- Save as Template->WSP
• Exports everything +content(optional) +onet.xml• Stored in Solution Gallery or at the Farm• $ListId:Lists/someListName• Considerations
– Use VS WSP import to trim or ‘featurize’ items– Web Templates are Features and can be upgraded
Relational Lists: Joins
• With relational lists, SPF 4.0 adds support for joins
• Joins can only be implemented by developers using the API, CAML or SharePoint Designer 2010
• New properties on SPQuery:– SPQuery.Join– SPQuery.ProjectedFields
• Use SPLinq instead of CAML to join two lists in code
Querying Large Lists
• If throttling is enabled & list limit exceeded threshold, users won’t be able to query lists by default via API
• Can override querying the large list settings provided Web App configured to allow it
• Override using:– SPQuery.RequestThrottleOverride– SPSiteDataQuery.RequestThrottleOverride
• Only users with proper permissions get override ability (set via policies)
Content Iterator
SPQuery query = new SPQuery(); query.Query = "<Where><Eq><FieldRef Name=\"MyIndexedField\"/><Value Type=\"Text\">FieldValue</Value></Eq></Where>" + ContentIterator.ItemEnumerationOrderByNVPField;
ContentIterator ci = new ContentIterator();
ci.MaxItemsPerQuery = 500;
ci.ProcessItemsInList(query,
delegate(SPListItem item)
{ // Work on each item. },
delegate(SPListItem item, Exception e)
{ // Handle an exception that was thrown while iterating. // Return true so that ContentIterator rethrows the exception. return true; } );
Questions ?
@laneyvbhttp://laneyvb.blogspot.com