Start a specific Workflow on all items in a List via Powershell

# URL of the Site
$web = Get-SPWeb -Identity “http://knowledgebase”

$manager = $web.Site.WorkFlowManager

# Name of the list
$list = $web.Lists[“knowledgebase”]

# Name of the Workflow
$assoc = $list.WorkflowAssociations.GetAssociationByName(“Update Author”,”en-GB”)

$data = $assoc.AssociationData
$items = $list.Items
foreach($item in $items)
{
$wf = $manager.StartWorkFlow($item,$assoc,$data,$true)
}

$manager.Dispose()
$web.Dispose()
#

Fix for Sharepoint 2010 issue with Workflows not firing with Content Organizer

When you attach a workflow to a document library that also has Content Organizer activated, and set that workflow to automatically activate on the addition or change of an item, sometimes the workflow will not fire – especially if a routing rule has been applied.

This fix watches for the addition or change of an item, and if the item is in a document library with the Content Organizer feature activated, it iterates through the attached automatic workflows and forces them to fire.

This is a known defect with Sharepoint 2010. You can read a current discussion here

Fix from our friends at CodePlex here 

 

The form cannot be rendered. This may be due to a misconfiguration of the Microsoft SharePoint Server State Service. For more information, contact your server administrator

You get this error, when trying to run a workflow manually via the FE or when using InfoPath Forms

Solution:
You would need to install the ‘State Service’ via the Configuration wizard in Central Administration or via PowerShell.

To configure the State Service by using Windows PowerShell:
1. Click Start, Administrative Tools, Windows PowerShell Modules.
2. In Windows PowerShell, type $serviceApp = New-SPStateServiceApplication -Name “State Service”
3. Create a State Service database and associate it with a service application, by typing New-SPStateServiceDatabase -Name “StateServiceDatabase” -ServiceApplication $serviceApp
4. Create a State Service Application Proxy and associate it with the service application by typing New-SPStateServiceApplicationProxy -Name “State Service” -ServiceApplication $serviceApp -DefaultProxyGroup
(You can use another proxy group if necessary by changing the DefaultProxyGroup parameter)

PS Code :

$serviceApp = New-SPStateServiceApplication -Name “State Service”
New-SPStateServiceDatabase -Name “StateServiceDatabase” -ServiceApplication $serviceApp
New-SPStateServiceApplicationProxy -Name “State Service” -ServiceApplication $serviceApp -DefaultProxyGroup

 

Tip:

You can view a list of all State Service cmdlets in Windows PowerShell by typing gcm *spstate*

Source : http://www.jeremytaylor.net/

 

SPD Workflow: Changes done to the workflow are not reflected on the site

The solution is to clear your PC’s cache. 

To do so, go to C:\Users\[Username]\ApPData\Local\Microsoft\WebsiteCache and delete everything there.

That’s what I did and it worked like a breeze.

.

.

.

.

If this doesn’t work then you can  try one of the following :

Solution 1:

  • Close SharePoint Designer.
  • Open the workflow settings of the list to which the worklfow is attached.
  • Remove all the previous versions of the workflow instances attached to the list. (Cleanup step)
  • Save the list as a template. NOTE: Select the Include Content checkbox.
  • Delete the list to which the workflow is attached.
  • Create a new list using the saved list template.
  • Open SharePoint Designer.
  • Open the workflow, perform any simple change (e.g. Log To History List) and click Finish.
  • Trigger the workflow -> The changes are refelected correctly.

Solution 2:

  • Close SharePoint Designer.
  • Open the workflow settings of the list to which the worklfow is attached.
  • Remove all the the workflow instances attached to the list,including the current version.
  • Open SharePoint Designer.
  • Create a new workflow on the same list and add any simple condition and any simple action to it.
  • Click Finish, in order to save and publish the new workflow.Note that the new workflow has the files [workflow name].xoml and [workflow name].xoml.rules.
  • Using Notepad, copy the content of the old “xoml” file into the new “xoml” file.
  • Using Notepad, copy the content of the old “xoml.rules”file into the new “xoml.rules” file.
  • Open the new worklfow and quickly go through all the conditions and actions, to make sure that no variables are corrupt. Note: In case you use a Collect Data From Useraction in your workflow, I recommend that you create a new action and remove the old one.
  • Click Finish, in order to save and publish the new workflow.
  • In case the new workflow is saved properly, delete the old workflow in SPD. This can be done by right-clicking the workflow’s name under the Worklfows node, selecting Delete and confriming the deletion when the warning message appears.
  • Finally, trigger the workflow -> The changes are refelected correctly.