SharePoint Designer Workflow fired twice in a migrated list

Recenlty i migrate a SharePoint 2007 list and imported that list into a SharePoint 2010 site using some stsadm extensions.

The list used to have an SPD Workflow, since SPD 2007 cant be migrared i recreate the workflow using SPD 2010. But I realize that every time the workflow was trigger it was fired twice.

After some test i review the list schema and found out that the list had reference to the Workflow event receivers  for both SharePoint 2007 and SharePoint 2010.

To get rid of those extra refence i created an small powershell script:

$spWeb = Get-SPWeb -Identity http://mySP2010site/mySP2010SubSite/
$spList = $spWeb.Lists[“MyList”]
$eventsCount = $spList.EventReceivers.Count
$assembly = “Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”
for ($i = 0; $i -lt $eventsCount; $i+=1)
{
      write-host $spList.EventReceivers[$i].Assembly
   if ($spList.EventReceivers[$i].Assembly -eq $assembly)
   {
      write-host  “About to delete the reference”
      $spList.EventReceivers[$i].Delete()
   }
}
$spList.Update()

 That solves my issue.

About these ads

2 thoughts on “SharePoint Designer Workflow fired twice in a migrated list

  1. Pingback: Migrazione SharePoint 2010 – SharePoint 2013: doppia esecuzione di un workflow alla creazione di un elemento | NonsoloSharePoint - Baxy's Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s