Archive for October, 2012

Displaying SharePoint list from top level or subsite in SharePoint 2010 Data View web part


In SharePoint 2010 Data view web part, there is no direct way to connect to Data Source of a different site in the same site collection.

What do we do when we need to fetch data from a list residing in the top level site or sub site in SharePoint 2010?

The answer to above question that generally crops up is to use a SOAP Service connection data source and connect data view to this data source.

I feel that we should go to this approach if there is nothing possible directly. The overheads in having another data source is that we have to keep updating the data source in case any column in the list is added. Once we update data source, then we need to update the Data view web part accordingly.

If we use default list data source, things would be pretty easier and there is no overhead.

Hence, I digged down in to the code to find out an alternative for this.

The solution is the usage of parameter viz. WebURL.

Pre-requisite: Configure the Data view web part to use List Name instead of List ID

In Data view web part, there is a tag <ParameterBindings> within which we have several <ParameterBinding> tags.

Add one as given below:

<ParameterBinding Name=”WebURL” Location=”None” DefaultValue=”/sites/top-site-name/”/>

There is a tag viz. <SPDataSources> within which we have <Select> tag.

Modify contents within <Select> tag as given below:

<SelectParameters><WebPartPages:DataFormParameter Name=”WebURL” ParameterKey=”WebURL” PropertyName=”ParameterValues” DefaultValue=”/sites/top-site-name/”/>

The same can be applied to InsertParameters, UpdateParameters, DeleteParameters.

Kindly comment if you are unable to follow the updates or face any issues.

Advertisements

How to migrate SharePoint 2010 List based workflows


How to migrate SharePoint 2010 List based workflows

Problem Statement:

We have a SharePoint 2010 list on our site and a workflow is associated to that list.

Sometimes, the existing list gets corrupt and we have to replicate the list using the list template saved earlier. Now, the existing workflow does not get associated to the new list and we have to re-create the entire workflow in SharePoint Designer.

Another scenario for associating an existing workflow is when the site is migrated; as, the workflow-list association is broken.

Solution:

Re-creating the entire workflow in SharePoint Designer can be a tedious process.

The alternative to this is to modify the source workflow files to force it to re-attach to the new list.

Note: There should be no schema mismatch between the old and new list.

When a workflow is created in a site for the first time, a Tasks list and a Workflow History list are automatically created/used by the workflow.

We will be using this concept for the migration.

Follow the below mentioned three steps in order to associate the workflow with the new list:

Step 1 – Create a Blank Workflow

  1. Using SharePoint designer, connect to your destination site
  2. Create a new list-based workflow called “test” (or any other name), attaching it to your migrated list
  3. Create one condition (e.g. if 1 = 1) and one action (e.g. add comment “hello”)
  4. Save and publish the workflow

Your site will now have a Tasks list and Workflow History list.

Step 2 – Get the List IDs for the new workflow

The list ids are required to configure your migrated workflow.

  1. Using SharePoint Designer, connect to your destination site
  2. In the left navigation page, under Site Objects, select All Files
  3. In All Files list, select Workflows
  4. Select your new workflow that you just created (in this example, “test”)
  5. You should see (at least) four files:
    text.xoml
    test.xoml.rules
    test.xoml.wfconfig.xml
    test.xsn
  6. Right-click on test.xoml.wfconfig.xml and select Open With, Notepad
    Look for the <Association…> tag in the xml:
    <Association ListID=”{770980F2-DA18-4089-96A2-066DF774BEA5}” StartManually=”true” TaskListID=”{DA6A8029-A1BE-4775-9E9B-1558CEA98791}” HistoryListID=”{44B38DD6-B5F1-4BF2-B063-B624DE88A207}”/>
    Record the GUID entries for ListID, TaskListID and HistoryListID.

Step 3 – Update the Existing workflow

  1. Using SharePoint Designer, All Files, Workflows, select your existing workflow
  2. You should again see (at least) four files. Right-click on “<your-workflow>.xoml.wfconfig.xml” and select Open with SharePoint Designer (As XML)
  3. Find the Association tag and very carefully change the GUIDs so that your migrated List IDs are the same as the “test” workflow List IDs
    Association tag
  4. Save the file
  5. Close SharePoint Designer
  6. Open SharePoint Designer again and open your site
  7. Instead of All Files, this time click on Workflows
  8. Select your workflow
  9. Save the workflow
  10. Publish the workflow

Your existing workflow should now be re-associated with the new list.

Reference:

http://gavinmckay.wordpress.com/2011/08/29/howto-move-or-migrate-sharepoint-2010-list-based-workflows-between-sites-and-site-collections/