Wednesday, 6 October 2010

jQuery intellisense

Problem: jQuery is pretty useful and I'm not great at creating it.
Hypothesis: I am using jQuery version jquery-1.4.2.js to get intellisence I need to reference jquery-1.4.1-vsdoc.js, this should be removed at deployment.  You can reference the Visual Studio jQuery Intellesense file (jquery-1.4.1-vsdoc.js) either from microsoft's CDN or deploy locally to the 14 hive.

References:
http://weblogs.asp.net/scottgu/archive/2008/11/21/jquery-intellisense-in-vs-2008.aspx
http://www.devcurry.com/2010/02/visual-studio-jquery-intellisense-over.html

Samples:
Get the input from a multiline text box/Textarea
var existingComments = $("[id*='txtComments']").val();
Explaination - txt comments is an text box namely: asp:TextBox runat="server" ID="txtCommentsAmend" TextMode="MultiLine".  val() gets the inner html/content.
Append additional data to the text box
$("[id*='txtCommentsAmend']").html(existingComments + 'more info');
Explaination - using the previous example variable append additional text in the textbox.

Saturday, 2 October 2010

Powershell to Move a Site Collection to a new Content Database

Problem: I have several site collections inside a single content database.  The content database is growing rapidly.  Backup and restore is fairly slow and SQL can start slowing down if the db is large enough.

Hypothesis: Create at least additional content db, move specific site collections to the new Content database.  I was surprised that moving site collections to content databases is not in the Central Admin (CA) UI.

Resolution: Create an additional content database either using PowerShell (PS) or the UI namely:
1.> CA > Application Management > Manage Content Databases > Add a Content Database (I called my content database "WSS_Content_Empty").
2.> Move the Site collection to the new content database using PS
3.> Check the database has been moved in CA

More Info:
http://technet.microsoft.com/en-us/library/cc825328.aspx

Set New Content Database using CA Only:
  1. UI only option to achieve the same result would be to create the new content database using CA as shown above. 
  2. Next using CA go to "Manage Content Databases", select the old/existing content database and set it to offline (This means that you can't add new content databases, existing site collections are still available).
  3. Adding a new Site Collection will now use the new/next content database that is ready/online.   
End of Post

Backup and Restore Powershell commands:
if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {
    Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}
cls
Backup-SPSite -Identity 'http://my.demo.dev/sites/kbtest' -Path C:\Projects\Backup\test.bak -Force -NoSiteLock -UseSqlSnapshot -Verbose
Restore-SPSite -Identity 'http://my.demo.dev/sites/newkbtest' -Path C:\Projects\Backup\test.bak -Force -Verbose 

Friday, 1 October 2010

Save site as template link missing in site settings

Problem: You want to create an WSP for your site however, the "Save site as template" link is missing from the "Site Settings" page as shown below.
Hypothesis: Deactivate the Publishing features namely: Manage Site features > Sharepoint Server Publishing & Site Collection features > SharePoint Server Publishing Infrastructure.   You know have the ability to create site templates i.e. wsp files.  The problem is you don't have your publishing infrastructure.

Resolution: If publishing is enabled on your site, craft a url so you can create the wsp file.  Url is http://demo/_layouts/savetmpl.aspx

Tip:  You can only include up to 50 MB of contentin SP2010

SP2010 Connections Conference in The Hague - Day 2

Managed Meta data in custom solutions by AC was a real eye opener.  Managed Metadata Service (MMS) is very powerful and i need to be using it to a much greater degree.  AC's earlier talk on WCM was interesting but not a technical discussion but we were warned so not AC's fault. 

Mirjam van Olst gave a presentation on Logging, Monitoring & throttling.  It's the 1st time I've been to 1 of her presentations and I was hugely impressed she really knows her stuff.

Dan Holme gave a good session on Information Architecture (IA) and the MMS.  Useful as after AC's session i decided i definatelty needed more MMS info.

The last session I went to Wouter van Vugt's session on Access Services - Access services could potentially be huge in SP2010 and it was good to see a techy like Wouter highlight what it was good and bad at.

Generally a good day and a good conference.  Not exactly Vegas 2009 or even Berlin 2007 in quality but worth the trip and met some nice people that are really passionate about SharePoint.

Tuesday, 28 September 2010

SP2010 Connections Conference in The Hague - Day 1

Keynote by Steve Fox was good but felt too sales orientated.  It's always hard to deliver a keynote at a  technical conference with the variety of attendees.  So overall not the worst and it covered a lot from previous conferences so not much new information outside of prepare for Azure with SharePoint.  Also SP1 for SharePoint 2010 will be available sometime in 2011 Q1.

Andrew Connell - AC is always good value however today he had a problem with his laptop/VM and the demos didn't work, still a good presentation on building RIA Rich Internet Applications or as the slide read "Rich Business Applications".  Looked at 2 demos for building RIAs using Silverlight client object model vs Restful web services (*.svc), nothing ground breaking but useful if you are new to using the Client Object model.
  • SharePoint apparently in it's page headers returns how busy the SharePoint server is with a number between 1-10, 10 being very busy.  You can see this in fiddler.
  • Anonymous user sites should generally use RESTful WS rather than Client OM/Silverlight as you need authentication. 
Ted Pattison's Extending the Visual Studio 2010 SharePoint tools was a great session.  Forget T4 templates.  Extensibility projects (VSIX) uses .NET4.0 and is based on MEF.  It's pretty straight forward and I can't wait to build some templates for SP2010.

Michael Noel's session on on Disaster Recovery & High Availability cover load balancing (use sticky sessions, Hardware is better than Sw load balancing), search options and improvements of MOSS search, SQL clustering and mirroring, use SQL alias's for pointing your farm at the db, common farm architectures, SP2010 and virtualisation (not ideal for SQL server), 3types of mirroring, Split content db's but not too small, Backup options and i need to review MS's DPM product.

Went to Andrew Connell's LINQ to SharePoint 201 Best practices.  Key takeaway is SPMetal only works on native SP Foundation types, M+LINQ to SharEPoint can be extended as it is implemented using partial classes, the iCustomise interface helps extend SPMEtal for more complex types such as Html fields and Metadata.

See Razvan-Petru Radu conference notes

Monday, 27 September 2010

SharePoint 2010 BCS workshop with Scot Hillier

Overview:  attended a workshop on Business Connectivity Services (BCS) given by Scot Hillier in Den Haag (The Hague).  I have used BDC in MOSS and the BCS in SP2010  briefly.  I can honestly say I am now a BCS convert.  I know BCS was an improvement on BDC but looking at the tooling and going building advanced BCS solutions is really powerful and covers a lot more that I understood or had seen in a previous demo.

Summary:
  • Office can use BCS - pretty obvious but I didn't realise the client application goes straight from the client application i.e. work/outlook to the SQL/WCF/.NET data type directly.
  • Double hop issue with NTLM.  Scot laid out a table to direct the options available for various scenarios that I will hopefully post here.
  • Secure Store Service is extensively used for authentication in BCS.
  • SPD has a good tool set for BCS.  Probably the place to start.
  • SQL 2000 doesn't work as an External Content Type (ECT) - this needs verification.
  • BCS doesn't support transactions and is not strongly typed however data access options can be intermingled to get transaction functionality if you need it. 
http://uscatu.wordpress.com/2010/09/30/business-connectivity-services-deep-dive-mdvwrk1-%e2%80%93-my-notes/  A far better summary was written by my fellow attendee Razvan-Petru.

BCS versions feature table

Thursday, 23 September 2010

Creating Site Columns / fields declaratively

Problem: Adding site columns decoratively has nuances.  This post adds information for getting fields/site columns correct when building them declarative using a feature to deploy to a Site Collection.

Resolution: You can use the following reverse engineering technique on the list.  This will show you the xml/CAML to create lists.  This works in MOSS & SP2010.  I used the list reverse engineering technique to figure out how to create a Lookup site columns with multiple values. 

Steps to Reverse engineering a SharePoint List:
1.> Create a list, content type and site column for the lookup (or field you want) using the SharePoint's UI
2.Then retrieve the list using a formatted url to see the native CAML used to create the site column.  http://url/_vti_bin/owssvr.dll?Cmd=ExportList&List=listguid
This approach saved me a lot of time today.

Tips:
CAML attributes required for each field element are: ID, Name, DisplayName, Group, and Type.
MSDN field element attributes
Attributes explained
Type="Note" will create a site column in the UI showing "Multiple line of text".  Attribute to get full html imput capabilities are RichText="True" (default is false)  & RichTextMode="FullHtml".
Type="Choice" can have a default value selected as shown below:
Built-in Site Column Append-only Comment can be referenced in a content type to provide comments that are appended and basic html is available.
Lookup columns work in SP2010 without having to create an event receiver to setup the lookup relationship using the list guid as is the case in MOSS.  Multiple lookups are possible also simple set the field attributes Type="Lookup" & Mult="TRUE".

Tip: Updated 18 Oct 2010 - CKSDev has the functionality to import Site Columns, this is useful in that you may of created the SiteColumns via the UI on a prototype site and you can not easily get the xml to create the site columns/fields declaritively. http://blog.mastykarz.nl/cksdev-support-importing-site-columns/