I also have that "Something went wrong..." every time I tried to run a workflow from a restored site collection. My solution was to republish all of my 50+ workflows with SharePoint Designer, and re-associate all of the reusable workflows with each list in the list settings.
That was a tedious job, so I resulted in creating two PowerShell scripts to do the republishing and resubscribing of workflows.
I hope that helps.
#--------Republish Workflows.ps1
Clear-Host
Write-Host -ForegroundColor Green $MyInvocation.MyCommand.Name
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
function RepublishWorkflows($siteName) {
$web = Get-SPWeb -Identity "http://$(hostname)/sites/$siteName" -ErrorAction SilentlyContinue
if($web) {
$wfm = New-object Microsoft.SharePoint.WorkflowServices.WorkflowServicesManager($web)
$depService = $wfm.GetWorkflowDeploymentService()
$wfsubService = $wfm.GetWorkflowSubscriptionService()
$wfDefs = $depService.EnumerateDefinitions($false)
foreach($wfDef in $wfDefs) {
$DefinitionId = $depService.SaveDefinition($wfDef)
$depService.PublishDefinition($wfDef.id)
if($wfDef.Properties.ContainsKey("SubscriptionId")) {
$sub = $wfsubService.GetSubscription($wfDef.Properties["SubscriptionId"].Trim("{}"))
$SubscriptionId = $wfSubService.PublishSubscription($sub)
}else {
$SubscriptionId = @{Guid="None"} #No SubscriptionId in definition (Reusable Workflow)
}
Write-Host ("{0,-75}{1,-20}{2,-45}{3,-0}" -f $wfDef.DisplayName, $siteName, $DefinitionId.Guid, $SubscriptionId.Guid)
}
}else {
Write-Host -ForegroundColor Yellow "Site $siteName does not exist"
}
}
Write-Host ""
Write-Host ("{0,-75}{1,-20}{2,-45}{3,-0}" -f "WorkflowName", "SiteName", "DefinitionId", "SubscriptionId")
Write-Host ("{0,-75}{1,-20}{2,-45}{3,-0}" -f "------------", "--------", "------------", "--------------")
RepublishWorkflows "MySite"
#--------Resubscribe Reusable Workflows.ps1
Clear-Host
Write-Host -ForegroundColor Green $MyInvocation.MyCommand.Name
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
function AddSubscription($listName, $workflow) {
$list = $Global:web.Lists["$listName"]
$wfTaskList = $Global:web.Lists[$workflow.TaskList]
$wfHistoryList = $Global:web.Lists[$workflow.HistoryList]
$wfDef = $Global:depService.EnumerateDefinitions($false) | where {$_.DisplayName -match $workflow.DefinitionName}
#Create Workflow Subscription
$sub = New-object Microsoft.SharePoint.WorkflowServices.WorkflowSubscription
$sub.DefinitionId = $wfDef.Id #{this is the id of the WorkflowDefinition}
$sub.Enabled = $true
$sub.Name = $workflow.SubscriptionName
#Build start options
$startOptions = New-Object System.Collections.ObjectModel.Collection[System.String]
#$startOptions.Add("ItemAdded") #When item added
#$startOptions.Add("ItemUpdated") #When item updated
$startOptions.Add("WorkflowStart") #Allow manual start
$sub.EventTypes = $startOptions
$sub.SetProperty("HistoryListId", $wfHistoryList.Id)
$sub.SetProperty("TaskListId", $wfTaskList.Id)
Try {
$devnull = $Global:wfSubService.PublishSubscriptionForList($sub, $list.Id)
}Catch {
if($_.Exception.InnerException -match "Microsoft.Workflow.Client.ActivityNotFoundException") {
Write-Host -ForegroundColor Yellow 'Please run "Republish Workflows.ps1" before executing this script.'
Exit 0
}else {
throw
}
}
}
function DelSubscription($listName, $workflow) {
$list = $Global:web.Lists["$listName"]
$tmp = $Global:wfsubService.EnumerateSubscriptions() | where {$_.Name -match $workflow.SubscriptionName -and $_.EventSourceId -eq $list.ID}
if($tmp) {
if($tmp.Count -eq 1) {
$Global:wfsubService.DeleteSubscription($tmp[0].Id)
}else {
Write-Host "............ More than one Subscription"
}
}
}
$Workflow1 = @{DefinitionName="MyReusable1";SubscriptionName="Test Workflow 1";TaskList="Workflow Tasks";HistoryList="Workflow History"}
$Workflow2 = @{DefinitionName="MyReusable2";SubscriptionName="Test Workflow 2";TaskList="Workflow Tasks";HistoryList="Workflow History"}
$listNameArray = "MyList1","MyList2"
function ReassociateReusableWorkflows($siteName) {
$Global:web = Get-SPWeb "http://$(hostname)/sites/$siteName" -ErrorAction SilentlyContinue
if($Global:web) {
$wfm = New-object Microsoft.SharePoint.WorkflowServices.WorkflowServicesManager($web)
$Global:depService = $wfm.GetWorkflowDeploymentService()
$Global:wfsubService = $wfm.GetWorkflowSubscriptionService()
foreach($listName in $listNameArray) {
DelSubscription $listName $Workflow1
DelSubscription $listName $Workflow2
AddSubscription $listName $Workflow1
AddSubscription $listName $Workflow2
Write-Host ("{0,-70}{1,-20}{2,0}" -f $listName, $siteName ,"...done")
}
}else {
Write-Host -ForegroundColor Yellow "Site $siteName does not exist"
}
}
Write-Host ""
Write-Host ("{0,-70}{1,-20}" -f "SubscriptionName","SiteName")
Write-Host ("{0,-70}{1,-20}" -f "----------------","--------")
ReassociateReusableWorkflows "MySite"