Monday, May 14, 2012

Add Lync Presence to SharePoint List column with XSL Stylesheet

If you want display Lync link with your contact list.
  1. Add column to the list Single line of text will call Presence.
  2. Edit Contact List Web Part Set XSL Link Property with new xsl.
  3. Create a XSL file with a style sheet, this style will add presence based on the Email field in the Contact list.
    <xsl:stylesheet xmlns:x="" xmlns:d="" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="" xmlns:asp="" xmlns:__designer="" xmlns:xsl="" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal" xmlns:o="urn:schemas-microsoft-com:office:office">
     <xsl:include href="/_layouts/xsl/main.xsl"/>
     <xsl:include href="/_layouts/xsl/internal.xsl"/>
     <xsl:template name="FieldRef_Text_body.Presence" match="FieldRef[@Name='Presence']" mode="Text_body">
      <xsl:param name="thisNode" select="."/>
      <xsl:variable name="etternavn">
       <xsl:value-of select="$thisNode/@Title" />
      <xsl:variable name="fornavn">
       <xsl:value-of select="$thisNode/@FirstName" />
      <xsl:variable name="fulltNavn">
       <xsl:value-of select="concat($fornavn,' ',$etternavn)" />
      <xsl:variable name="itemID">
       <xsl:value-of select="$thisNode/@ID" />
      <xsl:variable name="sipAfter">
       <xsl:value-of select="substring-after($thisNode/@Email,':')" />
      <xsl:variable name="sip">
       <xsl:value-of select="substring-before($sipAfter,'"')" />
       <div id="PresenceLink_{$itemID}"><span class="ms-imnSpan"><img border='0' height='12' src='/_layouts/images/imnhdr.gif' onload="IMNRC('{$sip}')" ShowOfflinePawn='1' style='padding-right: 3px;' id="PresencePawn_{$itemID}" alt='pawn' /> <a href='' id="ProfileLink_{$itemID}"><xsl:value-of select="$fulltNavn" /></a></span></div>

Tuesday, May 8, 2012

SharePoint Software Factory 2010

I found a free Visual Studio Extension helping SharePoint newbies, as well as experienced developers to create, manage and deploy SharePoint solutions without having to know every tiny XML and C# secret.

Key Features:
  • Get started with professional SharePoint development in less than 5 mins!
  • Use powerful wizards to create all important SharePoint artifacts
  • Fully integrated in Visual Studio
  • Refactoring of artifacts (i.e. Content Types)
  • Fully automated build system creates web solutions packages (“WSP”s) and deployment files 
  • Integrated Code quality checks in “Release” build (additional installs required)
  • All projects are self maintained, meaning that there is no dependency to having SPSF installed on the machine, when you just want to build, or continue development without SPSF
  • Standard VS2010 item templates for SharePoint development can be used together with SPSF projects, though the coding conventions have to be applied by the developers for these items
  • Extensive Help integrated in Visual Studio
  • Supports new SharePoint Visual Studio application structure but also “old” best-practice SharePoint Hive structure
  • Supports SharePoint 2007/2010 and Visual Studio 2008/2010
  • Upgrade existing SharePoint projects.
You can check this extension from link:

SharePoint Best Practices when use object model

When we run SharePoint Site Without any code customization we will notice big difference in performance. There are many common things affect performance with object model:

  • Dispose SharePoint Objects:
    SharePoint object model contains objects that implement the IDisposable interface. You must take precautions when using these objects to avoid their long-term retention in memory in the Microsoft .NET Framework.
    Specifically, you should explicitly dispose of those SharePoint objects that implement IDisposable when you are finished using them.
    The following unusual behaviors occurred when you did not disposing of SharePoint objects when you are finished with them

    1. Frequent recycles of the Windows SharePoint Services application pool, especially during peak usage.
    2.  Application crashes that appear as heap corruption in the debugger.
    3.  High memory use for Microsoft Internet Information Services (IIS) worker processes.
    4. Poor system and application performance.

    There are 2 articles contains best practice for disposing objects:

You can use SharePoint Dispose Checker Tool:
This tool helps developers and administrators check custom SharePoint solutions that use the SharePoint Object Model helping measure against known Microsoft dispose best practices.

  • Using SharePoint Data and Objects Efficiently

    1. Caching Data and Objects 
    2. Using Objects in Event Receivers
    3. Working with Folders and Lists
    4. Deleting Multiple Versions of a List Item
    5. Writing Applications That Scale to Large Numbers of Users

    There is article take about Common Coding Issues When Using the SharePoint Object Model:
  • Decrease round trips with the database:|
    When you access SharePoint using object model every time access . retrieve data from the database for example:
    If we loop over list items like:
    for(int i=0;i&lt;web.list["News"].Items.Count;i++)         
          SPListItem item = web.list["News"].Items[i];

    The best practice assign SharePoint Objects in variables and use these variable:
    SPList list = web.list["News"];
    SPListItemCollection itemCol= list.Items;                       
    for(int i=0;i&lt;itemCol.Count;i++)
          SPListItem item = itemCol[i];
    This role must be applied in most objects of SharePoint.
I found good engine called FASTSPWeb in codeplex help you to solve some problems:
  • Decrease database round trip by caching SharePoint objects automatically in the web application process and allowing multithreaded access to these objects.
  • Correct disposing of opened SPWeb and SPSite object is also not an issue because FASPSPWeb is handling all instantiating and disposing automatically.
This tool link is: