Monday, December 20, 2010

Cannot connect to the configuration database - SharePoint 2007/2010

Most of the times, developers get this annoying error message, see snapshot below:


One of the common reason for this error is when MSSQLServer instance is not running, go to
Start->Run->Services.msc and start the MSSQLServer Service as shown in the snapshot below:


And then refresh your SharePoint page, it starts working perfectly fine again.

Trying to use an SPWeb object that has been closed or disposed and is no longer valid.

"Trying to use an SPWeb object that has been closed or disposed and is no longer valid" error message is very common amongst developers dealing with the SharePoint object model. Here is how the error looks like:


The reason behind this is a silly mistake that developers do, when trying to use the SPSite/SPWeb objects. Here is the bad code that resulted in the error:



I used the using clause alongwith the SPContext.Current.Site which resulted in this error, it implicilty disposes the SPSite object which should not be done when using the SPContext object. Lets refactor the code a little bit and have a look at the good code snippet which resolved this issue:



Thats about it, my code started working when I removed the using clause from the SPContext.Current.Site. The same thing is true when you try to either explicitly/implicitly Dispose the SPContext.Current.Web object. So moral of the story never dispose SPContext objects either implicitly leveraging the using clause or explicitly by using Dispose method from in your finally block.

Watch out for the SharePoint Object Model coding best practices at : http://www.sharepointfix.com/2008/12/best-practices-disposing-sharepoint.html

Javascript:ShowModalDialog Relative Site Collection URL

Get the dynamic Site Collection URL working in your Javascript code:

{SiteUrl} - Replaces the full Site Collection URL within your Javascript:ShowModalDialog Relative URL path, use this piece of code to avoid hard coding URL's in your Custom Ribbon Action's Elements.xml file,

~site - This one does the same thing but can't be used in Context of the Javascript code, and can only be used within SharePoint.

Here is a sample Elements.xml Custom Ribbon Action code, which shows how to use the {SiteUrl}  and ~site property:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="OpenModalPopup"
RegistrationType="List"
RegistrationId="101"
Location="CommandUI.Ribbon">
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition
Location="Ribbon.Documents.New.Controls._children">
<Button
Id="Ribbon.Documents.New.Controls.DemoHelloWorldButton"
Alt="Open Modal Popup Ribbon Button"
Sequence="10"
Image32by32="/_layouts/images/SharePointFix/water.gif"
Command="OpenModalWindow"
LabelText="Update Profile Info"
TemplateAlias="o2"/>
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler Command="OpenModalWindow" CommandAction="javascript:SP.UI.ModalDialog.showModalDialog({~site/_layouts/SharePointFix/PrintListItems.aspx', title: 'Print List Items' });" />
</CommandUIHandlers>
</CommandUIExtension>
</CustomAction>
<CustomAction
Id="ExternalLink"
Description="Change your user profile country"
Location="Microsoft.SharePoint.StandardMenu"
GroupId="PersonalActions"
Sequence="0"
Title="Select Country View"
ImageUrl="~site/_layouts/images/SharePointFix/water.gif"
>
<UrlAction Url="javascript:(function () { var o = { url:'{SiteUrl}/_layouts/SharePointFix/PrintListItems.aspx', title: 'Select List Item', dialogReturnValueCallback: SP.UI.ModalDialog.RefreshPage }; SP.UI.ModalDialog.showModalDialog(o); }) ();"/>
</CustomAction>
</Elements>

Tuesday, December 7, 2010

How to go to the SharePoint Page Webpart Maintanance Mode?

There are 2 scenarios where we need the Webpart Maintanance Page to delete trouble making webparts from the current page:

a. At times the webpart we are developing might have code errors due to which the whole page hangs up or stops working entirely and redirects you to a SharePoint error message stack trace page.

b. Most of the times, we just tend to "Close" the unused webparts, while we are setting up our pages. But the webpart still remains hidden on the page and loads each time the page is called, even though not in use.

This might result in performance bottle necks, while loading the page as it loads unused webparts as well. The quickest and shortest route to fix the above is switching to the Page's Web Part Maintance Mode.

So, for eg: if your SharePoint Landing Page URL looks like this: http://sharepointfix:9999/Pages/default.aspx

In order to quickly switch to this pages webpart maintanance mode, you need to append the above URL with a ?Contents=1 query string parameter like this:
http://sharepointfix:9999/Pages/default.aspx?Contents=1

You can then delete the unused/not required webparts from this page, by checking on the webpart and clicking on the Delete option:

I hope this helps.

Wednesday, November 24, 2010

SharePoint 2010 Publishing feature GUID - Activation Dependency

This Publishing feature Activation Dependency within the elements.xml ensures that your custom feature gets activated only when Publishing feature is enabled on your respective site collection. Copy and paste the code below in your custom feature project elements.xml file -

<ActivationDependencies>
    <ActivationDependency FeatureTitle="Publishing Infrastructure" FeatureDescription="Publishing Infrastructure need to be activated prior to deploying the Custom PageLayouts, Site Content Types and Site Columns feature." FeatureId="f6924d36-2fa8-4f0b-b16d-06b7250180fa" />
  </ActivationDependencies>

If the scope of your feature is Web, then you can even ensure whether Publishing site feature has been activated on your subsite as well:

<ActivationDependency FeatureTitle="SharePoint Server Publishing" FeatureDescription="Option to create Custom Page Layouts will not be visible, unless you activate SharePoint Server Publishing feature at the web level." FeatureId="94c94ca6-b32f-4da9-a9e3-1f3d343d7ecb" />

Monday, November 22, 2010

Power Shell .wsp deployment scripts for SharePoint 2010

Copy the PowerShell scriptlet below and paste it in a notepad, modify your Site Collection URL in the code marked in yellow below and save it with a .ps1 extension.

Also have a look at Powershell script to deploy multiple solutions (.wsp) to your site collection. See the full post here: http://www.sharepointfix.com/2011/07/powershell-script-to-deploy-multiple.html
=======================================================================
Add-PsSnapin Microsoft.SharePoint.PowerShell

#Site Collection URL - Give your site collection url in quotation marks
$SiteUrl="http://localhost"

#Do not modify anything in the script from here onwards
function Get-ScriptDirectory
{
 $Invocation = (Get-Variable MyInvocation -Scope 1).Value
 Split-Path $Invocation.MyCommand.Path
}

#solutions to deploy
$SolutionName="PrintListItem.wsp"
$SolutionPath = Join-Path (Get-ScriptDirectory) $SolutionName
echo "Extracting information from $SolutionPath"

$SolutionPath= $SolutionPath
$FeatureName="PrintListItem_Feature1"

#Feature name
$FeatureID= $(Get-SPFeature -limit all | ? {($_.displayname -eq $FeatureName)}).Id
$SingleSiteCollection = Get-SPSite $SiteUrl

#Admin service
$AdminServiceName = "SPAdminV4"
$IsAdminServiceWasRunning = $true;

if ($(Get-Service $AdminServiceName).Status -eq "Stopped")
{
    $IsAdminServiceWasRunning = $false;
    Start-Service $AdminServiceName
   Write-Host 'SERVICE WAS STOPPED, SO IT IS NOW STARTED'
}

Write-Host 'DEACTIVATING FEATURE ...'

Disable-SPFeature -Identity $FeatureName -Url $SiteUrl -Confirm:$false
Write-Host 'FEATURE HAS BEEN DEACTIVATED SUCCESSFULLY.'

#Uninstall
Write-Host 'UNINSTALLING SOLUTION ...'

$Solution = Get-SPSolution | ? {($_.Name -eq $SolutionName) -and ($_.Deployed -eq $true)}

if ($Solution -ne $null)
{
    if($Solution.ContainsWebApplicationResource)
    {
        Uninstall-SPSolution $SolutionName -AllWebApplications -Confirm:$false
    }
    else
    {
        Uninstall-SPSolution $SolutionName -Confirm:$false
    }
}

while ($Solution.JobExists)
{
    Start-Sleep 2
}

Write-Host 'SOLUTION HAS BEEN UNINSTALLED SUCCESSFULLY.'

Write-Host 'REMOVING SOLUTION ...'

if ($(Get-SPSolution | ? {$_.Name -eq $SolutionName}).Deployed -eq $false)
{
    Remove-SPSolution $SolutionName -Confirm:$false

Write-Host 'SOLUTION HAS BEEN REMOVED SUCCESSFULLY.'
}

Write-Host 'ADDING SOLUTION ...'

Add-SPSolution $SolutionPath  | Out-Null

Write-Host 'SOLUTION HAS BEEN ADDED SUCCESSFULLY.'

Write-Host 'DEPLOYING SOLUTION ...'

$Solution = Get-SPSolution | ? {($_.Name -eq $SolutionName) -and ($_.Deployed -eq $false)}

#use '-force' paramater to install all commands in this if statement

if(($Solution -ne $null) -and ($Solution.ContainsWebApplicationResource))
{
Install-SPSolution $SolutionName –AllwebApplications -GACDeployment -Force -Confirm:$false
}
else
{
Install-SPSolution $SolutionName -GACDeployment -Force -Confirm:$false
}

while ($Solution.Deployed -eq $false)
{
    Start-Sleep 2
}

Write-Host 'SOLUTION HAS BEEN DEPLOYED SUCCESSFULLY.'

Write-Host 'ACTIVATING FEATURE ...'

if ($FeatureName -ne $null)
{
    Enable-SPFeature -Identity $FeatureName -Url $SiteUrl -Confirm:$false
}
#message
Write-Host 'FEATURE HAS BEEN ACTIVATED SUCCESSFULLY.'


if (-not $IsAdminServiceWasRunning)
{
    Stop-Service $AdminServiceName
}

Remove-PsSnapin Microsoft.SharePoint.PowerShell

Echo Finish

=====================================================================

Now create a new notepad file and copy the code mentioned below, and then save the below mentioned code in a .bat file to automate the PowerShell deployment.

cd /d %~dp0
powershell -noexit -file ".PrintListItemDeploymentScript.ps1" "%CD%"
pause

Friday, November 19, 2010

Custom Ribbon Actions in SharePoint 2010 - Elements.xml

Custom action to add a Ribbon button in the Display Form of a SharePoint List:

<CustomAction Description="Prints a single List Item" Title="Print List Item" Id="{055c63b4-58d8-4b4a-a366-70f69257b491}" Location="CommandUI.Ribbon.DisplayForm" RegistrationId="100" RegistrationType="List" Sequence="0" Rights="ViewListItems" xmlns="http://schemas.microsoft.com/sharepoint/">
    <UrlAction Url="~site/_layouts/PrintListItem/PrintListItem.aspx?List={ListId}&amp;ID={ItemId}" />
    <CommandUIExtension xmlns="http://schemas.microsoft.com/sharepoint/">
      <CommandUIDefinitions>
        <CommandUIDefinition Location="Ribbon.ListForm.Display.Manage.Controls._children">
          <Button Id="{C75857A4-C0BC-439A-813A-A1DCC885A14A}" Command="{06000B27-86BB-4203-AF44-29F61FDA678D}" Image32by32="~site/_layouts/Icon/PrintIcon.jpg" Image16by16="~site/_layouts/Icon/PrintIcon.jpg" Sequence="0" LabelText="Print List Item" Description="Prints a Single List Item" TemplateAlias="o1" />
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler Command="{06000B27-86BB-4203-AF44-29F61FDA678D}" CommandAction="~site/_layouts/PrintListItem/PrintListItem.aspx?List={ListId}&amp;ID={ItemId}" />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>

Custom action to add a Ribbon button in the Display Form of a SharePoint Task List:

<CustomAction Description="Prints a single List Item" Title="Print List Item" Id="{055c63b4-58d8-4b4a-a366-70f69257b491}" Location="CommandUI.Ribbon.DisplayForm" RegistrationId="107" RegistrationType="List" Sequence="1000" Rights="ViewListItems" xmlns="http://schemas.microsoft.com/sharepoint/">
    <UrlAction Url="~site/_layouts/PrintListItem/PrintListItem.aspx?List={ListId}&amp;ID={ItemId}" />
    <CommandUIExtension xmlns="http://schemas.microsoft.com/sharepoint/">
      <CommandUIDefinitions>
        <CommandUIDefinition Location="Ribbon.ListForm.Display.Manage.Controls._children">
          <Button Id="{C75857A4-C0BC-439A-813A-A1DCC885A14A}" Command="{06000B27-86BB-4203-AF44-29F61FDA678D}" Image32by32="~site/_layouts/Icon/PrintIcon.jpg" Image16by16="~site/_layouts/Icon/PrintIcon.jpg" Sequence="1000" LabelText="Print List Item" Description="Prints a Single List Item" TemplateAlias="o1" />
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler Command="{06000B27-86BB-4203-AF44-29F61FDA678D}" CommandAction="~site/_layouts/PrintListItem/PrintListItem.aspx?List={ListId}&amp;ID={ItemId}" />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>

Custom action to add a Ribbon button in the Display Form of a SharePoint Document Library:

<CustomAction Description="Prints a single List Item" Title="Print List Item" Id="{055c63b4-58d8-4b4a-a366-70f69257b491}" Location="CommandUI.Ribbon.DisplayForm" RegistrationId="101" RegistrationType="List" Sequence="1000" Rights="ViewListItems" xmlns="http://schemas.microsoft.com/sharepoint/">
    <UrlAction Url="~site/_layouts/PrintListItem/PrintListItem.aspx?List={ListId}&amp;ID={ItemId}" />
    <CommandUIExtension xmlns="http://schemas.microsoft.com/sharepoint/">
      <CommandUIDefinitions>
        <CommandUIDefinition Location="Ribbon.ListForm.Display.Manage.Controls._children">
          <Button Id="{C75857A4-C0BC-439A-813A-A1DCC885A14A}" Command="{06000B27-86BB-4203-AF44-29F61FDA678D}" Image32by32="~site/_layouts/Icon/PrintIcon.jpg" Image16by16="~site/_layouts/Icon/PrintIcon.jpg" Sequence="1000" LabelText="Print List Item" Description="Prints a Single List Item" TemplateAlias="o1" />
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler Command="{06000B27-86BB-4203-AF44-29F61FDA678D}" CommandAction="~site/_layouts/PrintListItem/PrintListItem.aspx?List={ListId}&amp;ID={ItemId}" />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>

Custom action to add an item in the Edit Control Block of a SharePoint List:

<CustomAction Id="PrintListItem.ItemToolbar"
  GroupId="PrintListItem"
  RegistrationType="List"
  RegistrationId="100"
  Location="EditControlBlock"
  Sequence="100"
  Title="Print List Item"
  ImageUrl ="/_layouts/Icon/PrintIcon.jpg">
  <UrlAction Url="~site/_layouts/PrintListItem/PrintListItem.aspx?List={ListId}&amp;ID={ItemId}"/>
</CustomAction>

Custom action to add an item in the Edit Control Block of a SharePoint Task List:

<CustomAction Id="PrintListItem.ItemToolbar" GroupId="PrintListItem" RegistrationType="List" RegistrationId="107" Location="EditControlBlock" Sequence="300" Rights="ViewListItems"
Title="Print List Item" ImageUrl ="/_layouts/Icon/PrintIcon.jpg"><UrlAction Url="~site/_layouts/PrintListItem/PrintListItem.aspx?List={ListId}&amp;ID={ItemId}"/></CustomAction>

Custom action to add an item in the Edit Control Block of a SharePoint Document Library:

<CustomAction Id="PrintListItem.ItemToolbar"
  GroupId="PrintListItem"
  RegistrationType="List"
  RegistrationId="101"
  Location="EditControlBlock"
  Sequence="300"
  Rights="ViewListItems"
  Title="Print List Item"
  ImageUrl ="/_layouts/Icon/PrintIcon.jpg">
    <UrlAction Url="~site/_layouts/PrintListItem/PrintListItem.aspx?List={ListId}&amp;ID={ItemId}"/>
    <!--<UrlAction Url="javascript:window.open('{SiteUrl}/_layouts/PrintListItem/PrintListItem.aspx?List={ListId}&amp;ID={ItemId}','PrintListItem','height=600,width=800,resizable=yes,scrollbars=1');"/>-->
  </CustomAction>

Custom action to add a Ribbon item in the SharePoint 2010 Standard Actions Menu of a SharePoint List:

<CustomAction   GroupId="ActionsMenu" Location="Microsoft.SharePoint.StandardMenu" Sequence="1000" Title="Print List Item" ImageUrl="/_layouts/Icon/PrintIcon.jpg" Description="Print list item" RegistrationType="List">
<UrlAction Url="~site/_layouts/PrintListItem/PrintListItem.aspx?List={ListId}&amp;ID={ItemId}" />
</CustomAction>

Will keep updating this post with more Custom Action elements in the future.

Thursday, November 11, 2010

Cross Site collection dropdown Look Up using JQuery

Often times you might need to do a sub-site or a cross site collection look up and populate it as a dropdown control in your SharePoint application. This is possible using JQuery. Here is the code for the same:

<script type="text/javascript" src="/sites/SPFix/JQueryDemo/JQueryDocumentLibrary/jquery-1.4.2.min.js"></script>

<script type="text/javascript">
$(document).ready(function() {
var soapEnv =
"<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>
<soapenv:Body>
<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>
<listName>Tasks</listName>
<viewFields>
<ViewFields>
<FieldRef Name='Title' />
</ViewFields>
</viewFields>
</GetListItems>
</soapenv:Body>
</soapenv:Envelope>";

$.ajax({
url: "/sites/SharePointFix/_vti_bin/lists.asmx",
type: "POST",
dataType: "xml",
data: soapEnv,
complete: processResult,
contentType: "text/xml; charset="utf-8""
});
});

function processResult(xData, status) {
$(xData.responseXML).find("z\:row").each(function() {
$('#crossSiteCollectionLookUp').
append($("<option></option>").
attr("value",$(this).attr("ows_Title")).
text($(this).attr("ows_Title")));
});
};
</script>
<body>
<select id="crossSiteCollectionLookUp">
</select>
</body>

1. Download and install the jQuery library from http://www.jquery.com/

2. Upload the jQuery library in any of your SharePoint document library and refer the path in the script source URL highlighted above. For best practices on integrating jQuery with SharePoint, refer: http://weblogs.asp.net/jan/archive/2008/11/20/sharepoint-2007-and-jquery-1.aspx

3. Drag and drop the Content editor webpart where you want to show your dynamic dropdown lookup column to be visible.

4. Copy and paste the  above code in the Content Editor webpart. Change the highlighted sections like List name, Column name, URL and Display column names as required in your scenario.

In the code snippet above, I am dynamically populating the Title column from my Tasks List in a Dropdown control.

Should work like a charm :)

Monday, October 18, 2010

SharePoint 2010 Enterprise Content/Web Content Management Features

New Enterprise Content Management (ECM) /Web Content Management (WCM) features in SharePoint 2010:

Ref #
Business Function
Description
1.   
Search
·         Interactive Search Experience – A richer search experience providing flexible navigation, refinement and related searches. Both Standard and FAST Search for SharePoint get query completion, spell checking, wild cards and more.
·         FAST Search - Seamless integration with FAST Search enhances the search experience enabling feature content for common queries and providing more flexible navigation and document thumbnails and previews including in slide navigation of PowerPoint presentations which is a common end user scenario.
·         Relevance – Search includes Out-of-box ranking and relevance factors including social data such as tagging and usage (clicks). FAST Search adds more configurable set of relevance inputs for custom applications and specialized corpuses.
·         People Search – People finding based on social networking and expertise algorithms and tailored user experience for people including getting views of authored content. As users frequently do not know or recall the spelling of people’s names, search includes a new phonetic search algorithm that works much better than previous approaches to spell checking for names.
·         Connectivity For data that lives outside SharePoint, search is expanded and improved with connectors to index web sites, file servers, SharePoint, Exchange, Lotus Notes, Documentum and FileNet. The updated Business Connectivity Services (previously the BDC) described below makes it much easier to index an arbitrary source such as a custom database. You can create this search connection without code using the new SharePoint Designer.
·         Scale and Platform Flexibility – Significant performance and scalability improvements through the new search technology. It also includes partitioned indices and scale-out query servers in SharePoint search. FAST scales-out even further and has significantly more pipeline extensibility to handle the largest collections and most complex value-added processing and search applications. The new capabilities support hundreds of millions of documents with great index freshness and query latency.
2.   
Metadata
·         Managed Metadata - Companies often require the use of approved terms from a centrally controlled taxonomy. The SharePoint 2010 response is managed metadata, which is the ability to create, manage, and publish term sets across the enterprise from a single point of reference.
·         Term sets - Term sets are hierarchical trees, internally connected structures that display parent-child relationships. Term sets and content type galleries are available to any site collection that can securely access the url for the managed metadata service.
·         Folders based metadata- Folders are now first-class objects in SP 2010. Documents and subfolders can inherit metadata from their parent folder making it easier to find documents when metadata is automatically added, instead of forcing users to add the same value over and over to the hundred documents they just uploaded.
3.   
Document Management & Classification
SharePoint 2010 adds scale and depth in the areas of Enterprise Content Management well advancing the user experience. ECM features are as follows:
·         Large Lists and Libraries – Support for much larger document libraries with metadata driven navigation to help users go quickly to the content that is most important to them. Libraries will scale to tens of millions and archives to hundreds of millions of documents. This is a key investment for high-end document and records management but also helps organizations with lots of smaller sites. Enhancement of the workflow capabilities and tools in SharePoint Designer.
·         Enterprise Metadata – Support for enterprise wide content types and taxonomies not only across sites but also server farms. Applying this metadata is made easy (and valuable to users) in both the SharePoint and Office client user experience. The top-down taxonomy and bottoms-up social tagging (sometimes called folksonomy) combine to help improve search, navigation and people connections.
·         Document Sets – A new way to manage a collection of documents as a single object for workflow, metadata, etc. within SharePoint and Office so experience more closely models your work product (e.g. a proposal that may contain a presentation, budget, contract, etc.).
·         Web Publishing including Digital Asset Management – A number of key improvements to make it easier to publish rich sites on the intranet or internet. The new browser ribbon and editor experience to speed site customization, content authoring and publishing tasks. Support for digital asset management features like thumbnails, metadata and ratings for images as well as video streaming from SharePoint.  Improved content deployment robustness from authoring to production for larger scale sites.
·         Governance and Records Management – Compliance is an increasingly important requirement for organizations. Enhanced Records Managements features in 2010 building on the scalable storage and enterprise metadata support described above. Just a few new features include location-based file plans, multi-stage dispositions, in-place records and e-discovery.
·         Social Feedback and Organization – SharePoint 2010 provides a consistent experience for organizing, finding and staying connected to information and people including bookmarks, tagging and ratings. It encompasses a new holistic approach across search, navigation, profiles, feeds and more. Bringing together informal social tagging with formal taxonomy described below so you can choose the right approach for a given set of content.
·         SharePoint Mobile Access – Improved the experience for mobile web browsers and are introducing a new SharePoint Workspace Mobile client so you can take Office content from SharePoint offline on a Windows Mobile device. These clients let you navigate lists and libraries, search content and people and even view and edit Office content within the Office Web App experience running on a mobile browser.
·         Content organizer - Content organization is largely a matter of individual upload decisions. Administrators could help guide those decisions, but ultimately, it was up to the contributors to decide where the content ended up. The new Content Organizer allows routing decisions to be centrally organized. It takes these decisions out of the hands of users and ensures that items are well organized. Users are guided to enter appropriate metadata rather than being allowed to dump documents wherever they like.
4.   
Audit
·         Granular Lists, Libraries, and Sites audit management – Granular Audit management/logging settings enables you to track opening or downloading documents, viewing items in lists, or viewing item properties, editing items, checking out or checking in items,
moving or copying items to another location in the site, deleting or restoring items. Includes editing content types and columns,
searching site content, editing users and permissions .
·         Audit Log Trimming - You also have the ability in 2010 to enable Audit Log Trimming which includes storing the current audit data in a Document Library.
·         ULS logs - ULS is improved through several facets including the introduction of a new and extensible Logging database, configurable noise suppression (Event Log Flood Protection), throttling, correlation Ids, and control of the amount of disk space used by logs as well as native compression of said logs - at the end of the day you can expect an approximate 50% savings in size of ULS logs as a result.
5.   
Workflow Management
·         Site and List level association - SharePoint 2010 workflow instances can be associated with a list item or a site.  
·         Reusable workflows - Reusable workflow points to content type (including base item content type), so it can be associated with any list. You need to prudent on associating the workflow to content type as content type associated columns will be available to the workflow.
·         Document Sets - Associate workflows with multiple documents using the new content type: Document Set (basically it is collection of documents).
·         Integration with Visio - Workflow can be imported and exported between SharePoint Designer and Visio. Visio only allows Sequential workflows. Stencils in Visio will have conditions, actions and connectors. Saves as standard Visio (.vsd) file. File menu allows export to workflow file (.vdi) file which is a compacted set of “xoml” file.
·         SharePoint Designer (SPD) Enhancements
a. Allows you to export as WSP or solution package. Can use .aspx or InfoPath forms in the workflow. Nested actions – step inside a step, conditional logic statements, look ups etc. Out-of-the box workflows (like Approval Workflow) is configurable using SPD. SPD allows you to create Workflow tasks.
b. Approval Workflow is configurable using SPD. SPD allowing you to create Workflow tasks.
c. Easy to create no-code workflow solutions with built-in ready-to-use workflow activities.

Sunday, October 10, 2010

Best Practices for developing Web Content Management (WCM) Portals using SharePoint 2010

Best Practices to consider while developing Web Content Management (WCM) portals using SharePoint 2010:

1. Prepare wired-frame diagrams for depicting screen layouts, developing a Proto-type in SharePoint is even better. It gives tremendous clarity to all the stakeholders and it becomes easy to communicate to your developers as well. Use Visio for this purpose.

2. Plan your web application topology well in advance. Identify when to use a site collection and when to use a subsite.

3. Define your taxonomies/folksonomy, use the SP 2010 managed metadata services.

4. Maintain separate content databases per  site collection, whenever you feel that your site collection can grow beyond 50 GB of data, move it into a separate content database, it becomes easier to manage and take back-ups and restore your web-application. SP 2010 recommended limit for content databases is a maximum of 100GB per site collection.

5. Always use content types, site columns for all your applications. Avoid creating columns directly in list/library.

6. Always limit the number of items in a List View using Filters.

7. Keep a very simple and a neat user interface with a user friendly navigation scheme.

8. Deploy your custom web parts, user controls, delegate controls, custom workflows as a feature solution package

9. Always prefer inheriting permissions for child sites, since they can be broken later.

10. Rigorously monitor your Application health using the new SP 2010 Developer dashboard for page response, memory leaks etc. ULS Diagnostic logging for errors etc.

11. Monitor your Content database size so that it does not exceed 100GB per site collection.

12. Use the new SP 2010 Folder Partitioning rules when your Document Library View items exceed the recommended 5000 item limit.

13. Always use Power Shell scripts to perform Solution installation, BackUp/Restore operations, Content database attach/detach, creating/deleting site collections and other Admin related operations.

14. Have atleast one Indexed column in your Lists for a performance reasons.

15. For moving content from staging to production environment, prefer using the new SQL Server 2008 Enterprise edition, Database snapshot technique which takes a quick snapshot of the Production farm and then ships it to the Destination farm.

16. You might convert your existing site collection to a solution file using SPD 2010 and open the solution using a Visual Studio 2010. and enhance it further. This is a faster way to build site definitions.

17. You can edit all List forms using InfoPath 2010, provided you have Enterprise edition of SP 2010. In this way you will be able to modify your New/Edit/Display forms using InfoPath 2010.

18. Use the advanced Record Management Rules for archiving, moving or marking documents as records. Alternatively InPlace records management is also available for declaring documents as records.

19. Prefer creating a Visual Webpart for better control over layout and ease of programming.

20. Prefer Creating Site Columns and Content Types programmatically over Features, the reason is when you add/update site columns in your custom content type, newly added/modified columns do not become immediately visible in the List/Page Content Type from the Parent Site Content Type.

Will keep updating this post with a lot more best practices in the future.

Wednesday, October 6, 2010

SharePoint 2010 Resources

SharePoint Products and Technologies (2010)

Microsoft SharePoint Server 2010 Evaluation Guide

SharePoint 2010: Getting Started with Development on SharePoint 2010 Hands-on Labs in C# and Visual Basic

SharePoint 2010: SharePoint Developer Platform Wall Poster

SharePoint 2010: Developer and IT Professional Learning Plan

SharePoint 2010: Professional Developer Evaluation Guide and Walkthroughs

Search Environment Planning for Microsoft SharePoint Server 2010

Design Search Architectures for Microsoft SharePoint Server 2010

Search Architectures for Microsoft SharePoint Server 2010

Getting started with business intelligence in SharePoint Server 2010

Topologies for SharePoint Server 2010

Hosting Environments for SharePoint 2010 Products

Cross-farm Services in SharePoint 2010 Products

Saturday, August 7, 2010

Managing SharePoint Projects Part 1 - Requirements Gathering and Analysis

Managing SharePoint Projects Part 1 - Requirements Gathering and Analysis, talks about the art of gathering & analyzing requirements for SharePoint projects.

In this post, I share my industry experience in handling customers, gathering requirements, setting expectations right and documenting requirements, so as to do things right the first time.

1. Project Roles/Structure:
The Business Development officer/Sales rep gets the project for the organization, he knows "What SharePoint can do and how it fits in the client requirements", he bids and gets the contract for the company, then interacts with the Delivery Manager to get the project done.

The Delivery manager has many projects to deliver under his department/region umbrella, so he passes it on to the Project Manager and gives him full authority and control over the project.

The Project manager has a SharePoint team in place to implement SharePoint projects. the team structure for a medium to large project implementation ideally comprises of a SharePoint Solution Architect, SharePoint Admin/Infrastructure team, Team/Project lead, a Test lead or Testing team and finally SharePoint team members for project implementation.

Again the above team composition is Project specific, in cases of small project implementations I have seen SharePoint developers playing all the above mentioned roles under the guidance of a team lead and project manager successfully.

2. Role-Responsibility:  Here is the roles-responsibilities mapping details:
  • Business Development Lead/Sales Rep - Managing Contracts, RFP's, High level bid estimates
  • Delivery Lead - Responsible for Project execution, has many projects under his umbrella.
  • Project Manager - Resource mobilization, Project Management activities include: Project Planning, Estimation, Risk management, Client interfacing, Co-ordination, Control and getting things done. Needs to create Business Requirements Document.
  • Project/Team Lead - Gathering/understanding requirements from the client, constant customer interaction/communication for clarifications, project progress, team meetings, progress/status checks, prevent effort/schedule slippage, may also play a part in the project estimation. Needs to create Software Requirements Specification and Use Case documents along with Use Case Diagrams.
  • SharePoint Solution Architect - Technical Architecture/Solution, Tools/Technology evaluation, Capacity Management, Hardware sizing, Farm scaling, High level and Detailed level technical diagrams
  • SharePoint Developer - Developer is responsible for actual technical implementation, creation of deployment scripts, unit test cases, code review (for custom features, infopath forms etc.), process/product quality, they might be additionally involved in Requirements Gathering or Estimation process.
  • SharePoint Admin/Infrastructure team - Responsible for SharePoint environment set-up, Configurations, Deployments, Back Up/Recovery, Disaster recovery, High Availability, Load balancing techniques like Network Load Balancing, Round Robin etc.
  • Test lead/Testing team - Responsible for System and Integration testing, creation of system/integration test cases, logging Defects/Bugs, discussion with development teams w.r.t to Product performance and quality.
Additionally there could be an organization specific Process Quality Group to measure and assess the project documents/artifacts vis-a-vis organization policies/standards.

3. Requirements Gathering and Analysis Participants:
Requirements Gathering & Analysis team can be formulated using the following permutations and combinations:
a. Project Manager and a Team Lead together
b. Team Lead and SharePoint Architect together
c. Team Lead and member/s of development team or
The above participants might be called as SharePoint Requirements SME(s)/Analyst(s).

For the sake of convenience, I will use the acronym RGA, which means Requirements Gathering Analyst(s) (can be an individual/group of individuals as mentioned above.)

4. Requirements Gathering and Analysis Techniques: 
The common techniques of gathering and analyzing SharePoint requirements are as follows:

a. Record your Discussions: Since RGA closely interfaces with the customer all the time, he needs to discuss with the customers, either face-to-face or live meetings or video conferencing. These discussions generally start with either their existing systems which they would like to re-engineer or migrate to SharePoint or a new system to be developed from scratch.

Its always a best practice to record these discussions in the background via some audio/video recording tool, in all cases make the customer aware that you are recording the sessions and get his approval before you do so. Firstly it is an important record/proof of what has been discussed and secondly you might want to re-visit for your own benefit.

Re-visit these recordings in case you are unclear or pass it on to the other team members parallely so that they have the feel of the project.

b. Dare to Ask Questions: Never assume things when gathering requirements, ask a lot of questions, let the communication be a two way process. Sometimes, you might interrupt and ask questions as well. I ask a lot of silly questions and get customer conformance as well.

Sometimes, there is a huge difference between what the customers literally say and what they actually mean. Like they would say as if they need only a Knowledge Management solution, but in reality they actually expect a Knowledge Management portal with Multi-lingual features, Advanced workflows, Advanced Reporting scenarios and other complexities as well.

The complexity and scope of project gets clarified only when you dare to ask questions.

c. Always Summarize: After each logical end of the discussion summarize your understanding and get customer conformance. In that way, you feel confident and customer is also happy that you have understood things properly.

d. Avoid unnecessary arguments:  Never argue with the customer unnecessarily, you may suggest but can't argue and put him off. That's not the objective. Remember Customer is always the king. Like it or not, but it is the ultimate truth. I have faced it a lot many times, when customer has made some sarcastic comments and I had to nod and take it in good humor.

e. Get to know the customer environment/policies: Especially with Banks & Financial Institutions, since they won't allow custom code, feature deployments, webparts etc in their SharePoint farm. Its always better to discuss this aspect in advance, as a lot of the requirements that you will discuss might need extensive customizations in SharePoint. In such a scenario, always mention it outright to your customers. There will always be a work-around process that involves communication between customers IT Infrastructure team and your team on the need to get custom dlls, features, web parts, third party tools etc. deployed in a safe and an effective manner.


f. Manage expectations: SharePoint is an over-hyped product, lots of customers have been tricked to believe that SharePoint can do everything out of the box. It is the job of RGA to set expectations right for the customer and communicate what can be done OOTB and what sections would need customization, I prefer to give them alternative options like third party tools, custom development as per the org environment policies etc and somehow try to create a Win-Win situation.

g. Wired frame diagrams/Proto-type: Its always a good practice to create wire-frame diagrams and get customer buy in. Proto-types are even more effective, but it all depends on the nature of requirements and time pressures. I prefer to make proto-types for complex projects, for lesser complex projects, Wired-frame screen diagrams would generally suffice.

h. Final Output: At the end of the day, what matters is the final output, the RGA should be effectively able to write a Business Requirements Document (BRD), Use Case Requirements Document, System Requirements Specifications document (SRS) and Requirements Tracking and Traceability (RTT) document.

i . Use Case Specifications document: Here we document the User-System interaction with appropriate Use Case diagrams, Preconditions, Post-conditions, Normal Flow and Alternative Flow.

ii. Business Requirements document (BRD): Here we document the Business Perspective/Business need. Use case ids are linked to each Business Requirement.

iii. System Requirements Specifications (SRS): System requirements is again the System requirements documented in detail, it links with the Use Case document and the BRD.


iv. Requirements Traceability Table (RTT): Its an excel sheet that maps the Business Requirements Ids with appropriate Use Case document ids and SRS ids. It will also map the Unit & System Test Case Ids for each Business Requirement ID.

Future posts: Managing SharePoint Projects Part 2 will cover Estimating SharePoint Projects, which will be an interesting post to watch out for, since there is no standard methodology like Function Points etc to estimate SharePoint projects.

I hope you like this post, keep posting your valuable comments, I will like to respond to each one of you.

Tuesday, July 27, 2010

How To: Add a new Content Database in SharePoint 2010

You can use the procedures that are described in this article to create a new content database and attach it to a Web application.

In this article:
  • To add a content database to a Web application by using Central Administration

  • To add a content database to a Web application by using Windows PowerShell

To add a content database to a Web application by using Central Administration

  1. Verify that the user account that is being used to perform this operation is a member of the Farm Administrators SharePoint group. If you are using Windows authentication to connect to SQL Server, the user account must also be a member the SQL Server dbcreator fixed server role on the SQL Server instance where the database will be created. If you are using SQL authentication to connect to SQL Server, the SQL authentication account that you specify when you create the content database must have dbcreator permission on the SQL Server instance where the database will be created.
  2. On the SharePoint Central Administration Web site, click Application Management.
  3. In the Databases section, click Manage content databases.
  4. On the Manage Content Databases page, click Add a content database.
  5. On the Add Content Database page:


    1. Specify a Web application for the new database.

    2. Specify a database server to host the new database.

    3. Specify the authentication method that the new database will use and supply an account name and password, if they are necessary.


      Important:
      The account name and password must already exist as a SQL Server login.
    4. Specify the name of the failover database server, if one exists.

    5. Specify the number of top-level sites that can be created before a warning is issued. By default, this is 9,000.

    6. Specify the total number of top-level sites that can be created in the database. By default, this is 15,000.


      Note:
      For information about how to determine the number of top-level sites that the system can support, see Performance and capacity technical case studies (SharePoint Server 2010).
    7. Click OK.

To add a content database to a Web application by using Windows PowerShell

  1. Verify that you meet the following minimum requirements: See Add-SPShellAdmin. If you are using Windows authentication to connect to SQL Server, the user account must also be a member the SQL Server dbcreator fixed server role on the SQL Server instance where the database will be created. If you are using SQL authentication to connect to SQL Server, the SQL authentication account that you specify when you create the content database must have dbcreator permission on the SQL Server instance where the database will be created.
  2. On the Start menu, click Administrative Tools.
  3. Click SharePoint 2010 Management Shell.
  4. At the Windows PowerShell command prompt, type the following command:

    New-SPContentDatabase -Name  -WebApplication 
    Where is the name of the content database to create and is the name of the Web application to which the new database is attached.
    For more information, see New-SPContentDatabase.

    Adopted from: Microsoft TechNet Article

Creating Site Collection in a separate Content Database

Since, most of us ignore the site collection basics and seldom plan our site collection content database storage needs. We are often unaware of SharePoint limitations in terms of content storage which affects our design at a later point in time.

Here is the simple yet very powerful stsadm command to create a site collection with a separate content database:

stsadm -o createsiteinnewdb -url http://webspinners/dept/hr -owneremail SharePoint@webspinners.com -ownerlogin Webspinners\SPAdmin -sitetemplate sts -title “Human Resources” -databaseserver "SERVER5" -databasename “HR Content Database”

In this example, a new site collection is created at the URL http://webspinners/dept/hr.
The Site Collection Owner is set to Webspinners\SPAdmin and the Site Collection owner email is set to SharePoint@webspinners.com.
The default team site template is used to create the site (the template is simply named ‘sts’, without the quotes.)
The database server is SERVER5 and the name of the database created is HR Content Database.
There are some reasons, why you could have a different content databases per site collections:

1. MS recommends to have content database not more the 100Gb for MOSS 2007 and 200GB for SP 2010.

2. It simplifies your backup and restore operation

3. It provides flexibility for Disaster Recovery (DR) strategy.

4. Modularity and Flexibility of data storage eliminates maintenance nightmares.

Possible Scenarios:
a. Media management for a site collection that stores heavy audio/video media files like .avi, .mpeg, .wav, .mp3

b. Knowledge Management requirement where you might think of implementing a separate KM site collection for managing thousands of word, excel, powerpoint, visio, pdf artifacts etc.

These scenarios need you to have a separate Content Database for your site collections, otherwise the overall application performance would degrade, searching these documents will be affected, backup and recovery will be a nightmare and moving these site collections into separate SP farms will be trouble some.

If you have already made the mistake of not having a separate content database store for your Site Collection, and want to move your Site Collection to a separate Content database in MOSS 2007, please follow these links :
http://msmvps.com/blogs/laflour/archive/2008/10/14/tips-to-create-a-site-collection-in-new-content-database.aspx
 and
http://blogs.msdn.com/b/mcsnoiwb/archive/2007/08/20/how-to-create-site-collection-in-a-specific-content-database.aspx

For moving site collection to a new Content DB in SharePoint 2010,  follow directions given by Microsoft : http://technet.microsoft.com/en-us/library/cc825328.aspx

Monday, March 29, 2010

Creating a Multiple selection List Box in browser enabled InfoPath form

InfoPath 2007 browser enabled forms (a part of InfoPath Form services) does not support Multi-select List Box control. Read some other InfoPath Form services limitations here: http://office.microsoft.com/en-us/infopath/HA102040851033.aspx

I had a tough time explaining and convincing clients about this and they got another excuse of blaming it all on Microsoft, so I finally decided to solve this problem on my own.

The overall solution looks like this:
a. Create a  custom Data structure in InfoPath 2007 browser enabled form.
b. Bind a Repeating Table with our custom Data Structure and tweak the look and feel to make it look more like a Multi-select List box.
c. Use Form Load event for programmatically loading Multi-Select List options.
d. On Submit button click, Save the multi-selected List box items as a semi-colon separated string in another InfoPath text field.

I will explain the above solution Step-by-Step with snapshots to make it more easier to implement.

a. Create a Data Structure in InfoPath 2007: See the snapshot below:

i) In this case, my field name for storing the values selected in the multi-select List items is WorkcenterAssignment. You can give any name you want to the Group and the field. Values selected by the user will be stored in this field.

ii) For MultiSelectOptions, follow the same structure as mentioned below:
-MultiSelectOptions(Repeating Group) - Will be applied as a repeating table in Step b.
    - selectedOption (True/False Boolean field) - This will be converted into Checkbox on the UI
    - optionDescription (Text string field) - This will be used for storing the multi-select List Item options

b. Bind a Repeating Table with the Data Structure
i) Right click on the above schema -> Choose Repeating table as follows:

ii) It will look like this on the InfoPath form:
iii) Format it to look more like a multi-select ListBox on your form:
Note: You can also wrap it inside a Table with a fixed width and fixed height, so that Listbox items can act like scroll bar for options)

c. Programmatically loading Multiple items in the List Box from SharePoint List/Library:
Now that our schema and control are all set, we need to load values into multiselect Listbox control.
The key event here is the InfoPath form load event. 

The strategy here is to bind the repeating table created above programmatically using Visual Studio for Applications. I prefer to write the code in C# .NET.

Here is my Form Load event, I call the generic method LoadMultiSelectListBox() method, copy the code below:

 public void FormEvents_Loading(object sender, LoadingEventArgs e)
        {
            try
            {
                this.Errors.DeleteAll();

                    XPathNavigator root = MainDataSource.CreateNavigator();
                    XPathNodeIterator listItems = root.Select("/my:Request/my:WorkCenterAssignments/my:MultiSelectOptions", NamespaceManager);

                    if (listItems.Count == 1)
                    {
                        //Load Multi-Select List Box
                        LoadMultiSelectListBox();
                    } 
            }
            catch (Exception exp)
            {
                ThrowException(exp);
            }
        }



Here is the code for Loading Multi-Select items into the repeating table programmatically. I first need to get all my List item options from my SharePoint List/Library, I have created a XML Receive Data connection in InfoPath, you can alternatively get all the options from SharePoint List/Library using the SharePoint object model, copy code below:

        private void LoadMultiSelectListBox()
        {
            try
            {
                this.Errors.DeleteAll();

                //Query Get Approvers From SharePoint List data connection
                FileQueryConnection queryConnection = (FileQueryConnection)this.DataConnections["WorkCenterXML"];
                queryConnection.Execute();

                //Get all nodes from the Work Center XML
                XPathNavigator connectionNav = DataSources["WorkCenterXML"].CreateNavigator().SelectSingleNode("//rs:data", this.NamespaceManager);
                XPathNodeIterator allItems = connectionNav.Select("//z:row", this.NamespaceManager);

                //Iterate via all records
                foreach (XPathNavigator item in allItems)
                {
                    AddMultiSelectListItems(item);
                }

                //Delete the first row of InfoPath Repeating table programmatically
                if (GetCurrentXPathNav("/my:Request/my:WorkCenterAssignments/my:MultiSelectOptions[1]") != null)
                {
                    GetCurrentXPathNav("/my:Request/my:WorkCenterAssignments/my:MultiSelectOptions[1]").DeleteSelf();
                }
            }
            catch (Exception exp)
            {
                ThrowException(exp);
            }
        }

This method adds values into our custom repeating table data structure:

        private void AddMultiSelectListItems(XPathNavigator item)
        {
            try
            {
                this.Errors.DeleteAll();

                //Get Reference to Multi-Select List Options
                XPathNavigator Item = GetCurrentXPathNav("/my:Request/my:WorkCenterAssignments/my:MultiSelectOptions");

                //Create a new Item node for Multi-Select List items
                XPathNavigator newItemNode = null;

                if (Item != null)
                {
                    //Clones the new item w.r.t repeating table structure
                    newItemNode = Item.Clone();
                }

                //Get Reference to Option description
                XPathNavigator optionDescription = newItemNode.SelectSingleNode("/my:Request/my:WorkCenterAssignments/my:MultiSelectOptions/my:optionDescription", this.NamespaceManager);

                //Set Option description values
                optionDescription.SetValue(item.GetAttribute("ows_Workcenter", String.Empty));

                //Add a new Item in the Multi-Select List options
                Item.InsertAfter(newItemNode);

                optionDescription = null;
                newItemNode = null;
            }
            catch (Exception exp)
            {
                ThrowException(exp);
            }
        }

Updated as on 5th April, 2010: GetCurrentXPathNav is a generic method used to get the handler on the particular node/field in InfoPath, copy the code below:

///
/// Get XPath Navigator gets the Navigator object for the passed in XPath expression.
/// This method should be used as a helper function at all times
///
/// XPathNavigator
public XPathNavigator GetCurrentXPathNav(String XPath)
{
    XPathNavigator DataSource = MainDataSource.CreateNavigator();
    XPathNavigator XPathNav = DataSource.SelectSingleNode(XPath, NamespaceManager);
    return XPathNav;
}

Preview your InfoPath form, your control should load all the options dynamically and look like this:

d. Saving the values selected from the Multi-select List box item on saving the form:
Assume user selects multiple items, we will have to save the values selected in our Multi-select Listbox control using a separate field in the InfoPath form, in this example, we created the WorkcenterAssignment text field in Step a.

Again we will use the programming approach to iterate through the repeating table nodes, identify the list items selected and store them as semi-colon (;) separated values in the WorkcenterAssignment InfoPath field.

WorkcenterAssignment can be further promoted as a SharePoint column using Property Promotion feature in the InfoPath form. To know more on publishing and deployment of InfoPath forms, see my detailed post on Publishing and Deploying browser based InfoPath forms


Here is the code to Save the selected Multi-select Listbox items:

private void SaveMultiSelectListItems()
        {
            try
            {
                this.Errors.DeleteAll();

                XPathNavigator root = MainDataSource.CreateNavigator();
                XPathNodeIterator listItems = root.Select("/my:Request/my:WorkCenterAssignments/my:MultiSelectOptions", NamespaceManager);

                String optionsSelected = String.Empty;
                StringBuilder selectedListItems = new StringBuilder(String.Empty);

                int counter = 0;

                while (listItems.MoveNext())
                {
                    optionsSelected = listItems.Current.SelectSingleNode("my:selectedOption", NamespaceManager).Value;

                    //Check whether the Check box against the option was selected or not
                    if (Boolean.Parse(optionsSelected) == true)
                    {
                        if (counter == 0)
                        {
                            selectedListItems.Append(listItems.Current.SelectSingleNode("my:optionDescription", NamespaceManager).Value);
                        }
                        else
                        {
                            selectedListItems.Append("; " + listItems.Current.SelectSingleNode("my:optionDescription", NamespaceManager).Value);
                        }

                        //increment the counter
                        counter++;
                    }

                    //Clear variable
                    optionsSelected = String.Empty;
                }

                //Set all the multi-selected List Box values
                GetCurrentXPathNav("/my:Request/my:WorkCenterAssignments/my:WorkcenterAssignment").SetValue(selectedListItems.ToString());
            }
            catch (Exception exp)
            {
                ThrowException(exp);
            }
        }


I think the above code is self-explanatory. This is how we simulate a Multi-select List control using the repeating table model and dynamic options loading in a browser enabled InfoPath form.

Feel free to share your comments.


References: InfoPath Team blog

Sunday, March 7, 2010

Enable Forms Based Authentication (FBA) in SharePoint 2010

Upcoming Posts: Have not been regular with my blogging in the last month, did lots of R&D on the InfoPath 2007 browser enabled forms and Form services, my future posts will be in the following areas:

A) Multi-select List Items in a browser enabled InfoPath form, which was earlier thought not to be possible with Form Services, stay tuned for that post.

B) Cascading dropdowns using code-behind InfoPath solution and owssvr.dll for dynamic filtering within the dropdowns using XML.

Coming back to Forms Based Authentication, here is a nice step-by-step tutorial, I found on Enabling Forms Based Authentication in SharePoint 2010: http://blog.summitcloud.com/2009/11/forms-based-authentication-sharepoint-2010-fb/

For enabling FBA on SharePoint 2007, refer:  http://blog.summitcloud.com/2009/10/enable-forms-based-authentication-for-sharepoint/

Stay tuned for my interesting hacks on InfoPath 2007. Till then Happy Programming :)

Thursday, January 14, 2010

Nintex My Workflow tasks webpart - Redirect to Custom InfoPath Task form

My earlier post related to a unique problem in Nintex OOTB "My Workflow Tasks" webpart. The job of this webpart is to show all Workflow Tasks assigned to the currently logged in user.

The problem occurs when InfoPath forms come into picture, since we might have a custom InfoPath task form, and the default behavior of the webpart directs the user to the Nintex OOTB task form, so it is has no provision for redirecting users to a Custom InfoPath Task form.

There are 2 possible ways to overcome this limitation:

Approach 1: in this approach I create a new custom InfoPathApproveReject.aspx form which overrides the OOTB Nintex ApproveReject.aspx Task form and hides certain section of the form like the Approve/Reject radio buttons. Check out Approach 1 here
 
Approach 2: Is modifying the existing Nintex OOTB ApproveReject.aspx task form in the 12 Hive layouts directory. The approach is to identify whether the ItemProperties contain .xml as an extension or not, so we use the following code in the ApproveReject.aspx page:

 if (this.itemProperties.Item.Name.ToString().Contains(".xml"))
   {
          string redirectUrl = this.itemProperties.Item.Web.Url + "/_layouts/FormServer.aspx?XmlLocation=" + this.itemProperties.Item.Web.Url + "/" + this.itemProperties.Item.Url.ToString() + "&OpenIn=browser";
          Response.Redirect(redirectUrl);
   }

This will work for all web applications in your SharePoint environment. If it is a custom InfoPath form in the Item Properties object, then it simply redirects the logged in user to the Custom InfoPath task form, otherwise it shows up only the OOTB Nintex task form.

Click here to download the customized version of Nintex ApproveReject.aspx form.  

NOTE: Take a back up of your existing copy of OOTB ApproveReject.aspx page from the following location C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\NINTEXWORKFLOW.

Then replace the customized version of ApproveReject.aspx page in the above mentioned location.

Test your changes:
To test the new change, you need to have a workflow enabled List/Library with a custom infopath form and Nintex OOTB My Workflow Tasks webpart on any of your site page.

Now when the task gets created it shows up in the webpart and when you click on the Item it opens up the InfoPath custom task form.

However, if you have a standard workflow on a SharePoint list/libray without InfoPath form, then you need not worry, since it would automatically open up the OOTB Nintex task form as it never found .xml within the ItemProperties object.