This example will demonstrate how to combine task lists created in Microsoft Office SharePoint Server 2007 (MOSS) with the standard Worklist provided by K2.net. The consolidated view is just for illustration purposes and can easily be customized for new implementations.
Users may at times be required to see a consolidated view of all the task items that require their attention. This would include items originated from K2.net or from a SharePoint Server 2007 list library. To achieve this, a simple web page can be created. The applicable lists in SharePoint as well as the K2.net Worklist are then queried and the results combined in a single list that can be hosted in a web page viewer web part on any page in SharePoint.
The application provided with this article provides sample code on how to query a SharePoint Server 2007 list and populate a data table with all the items assigned to the current user that is logged on. The same data table will also be populated by items in the user's K2.net Worklist. This data table will then be bound to an ASP.NET 2.0 GridView component for display.
|Note: The application needs to be hosted on the same server as SharePoint. This is a requirement of the SharePoint libraries being used.|
The following steps illustrate how to create a new web application and how to host a web page that will query and display items as a SharePoint task list:
- Open Visual Studio 2005 and create a new web application
- Add a reference to the SharePoint library assembly by right clicking on the Visual Studio solution, selecting "Add Reference." and then selecting the "Browse" tab in the "Add Reference" dialog
- Browse to the folder where the SharePoint library assemblies have been installed to (By default they are in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\ISAPI) and add a reference to "Microsoft.SharePoint.dll"
- Create a new web page to host your list and import the following namespaces to the code behind of the new page:
- Add a Gridview control to your web page. This will be used to display the list items
- Query the applicable SharePoint lists
- Iterate through the items in the list and add them to your chosen data source. In this case we are adding a new data row object for each task list item
- Add a reference to the K2 Runtime Object Model called K2ROM.dll, usually located in C:\Program Files\K2.net 2003\Bin. The SourceCode.K2ROM namespace also needs to be imported
- Use the standard K2ROM API calls to retrieve logged on user's K2.net Worklist and populate data source with the information required
- Finally, bind the populated data source to the Gridview control. This will display all the items belonging to the current logged on user:
To further enhance the combined task list, you can choose to convert it to a SharePoint web part. This will allow users to easily configure settings within the SharePoint Server User Interface. Examples on creating web parts for MOSS:
See attached web site called "MOSSTaskListNonAjax" for a full code example. The attached example also has a web site (called "MOSSTaskList") using AJAX to enhance the end user experience. For more information on AJAX: