[Edit] Rewrote the question, as there are simpler ways to reproduce the problem. [/Edit]
I have built a reusable workflow with SharePoint Designer 2010.
I saved the workflow as template, grab the wsp file, then upload the solution file to the site solutions catalog of another SharePoint farm (based on the same template, same features activated, etc.).
After activated the solution, activated the workflow feature, everything works as expected and I can run successfully my workflow.
Now I want to uninstall the workflow of the target site.
If I deactivate the workflow, the whole site is broken. I get a lot of errors like :
Nom de champ incorrect. {fa564e0f-0c70-4ab9-b863-0177e6ddd247} http://server/sites/sitecoll
(can be translated into incorrect field name)
The Title column has actually been removed from the site!!! (the item content type does not show this column anymore).
When I extract the content of the wsp file, I can see in the file MyWSP\1MyWFNameListInstance\Elements.xml
the following definition :
<Field ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}"
Name="Title"
SourceID="http://schemas.microsoft.com/sharepoint/v3"
StaticName="Title"
Group="_Hidden"
Type="Text"
DisplayName="Titre"
Required="TRUE"
FromBaseType="TRUE"
Customization=""
ShowInNewForm="TRUE"
ShowInEditForm="TRUE"
/>
I imagine that SharePoint is bit confused, and remove everything defined in the elements.xml.
So my question is :
- what is the correct way of deploying SPD 2010 workflows from one site to another ?
- Why can't I remove such a workflow by deactivating the solution ?
- how can I correct this ?
[Edit] Old version my question below :
I have exported a workflow from SPD 2010.
I add the solution to the site's solution catalog using the script :
function AddAndInstallUserSolution([string]$solutionFile, $site) {
$solution = get-item $solutionFile
$solutionName = $solution.Name
Add-SPUserSolution -LiteralPath (get-item $solutionFile) -Site $site -Confirm:$false
Install-SPUserSolution -Identity "Suivi des idées.wsp" -Site $site
$solution = Get-SPUserSolution $solutionName -Site $site
Write-Host ("Waiting for the activation of " + $solution.Name) -NoNewLine
while ($solution.Status -eq "Activated")
{
write-host .
Start-Sleep -Seconds 1
}
}
this is working as excepted, the workflow feature can be activated and the workflow files are provisionned.
Later, I want to disable and remove this solution. As soon as I call "Uninstall-SPUserSolution", the site is broken. Some native fields are removed, notably the Title column.
Why does this cmdlet remove natives fields and what should be the correct procedure ?