Tag Archives: Workflow

Get notified whenever a SharePoint workflow fails


Get SharePoint to notify you whenever a workflow fails to start.


Configure a SPD notification workflow for the Workflow History list so that it sends you an e-mail every time a workflow fails to start. This is relatively simple to do and all you need is full control permissions to the site. Your SharePoint admin will also need to enable the use of SharePoint designer.

Open SharePoint designer and browse to the site.

Go to All Files -> Lists -> Select your workflow history list, by default this is “Workflow History”.

Right click on Workflow History and click Properties.

On the top ribbon, select List Workflow

Type a name for the workflow, e.g. ‘Failure Notification’.

Set up the SPD workflow like how it is in the following screenshot and set it to run on item creation only.

SPD Workflow

Configure your e-mail template so that it includes the “Primary item ID”, “Date Occurred” and “Description” field. This will help you identify which workflow failed so you can manually restart it again. It would be helpful to include the url to the workflow history list as well in your e-mail template. The URL should look something like:


Click on Publish

Now whenever a workflow fails to start, you should receive an e-mail.



Comments ( 0 )

Re-assign a workflow task that is not assigned to you


Allow certain users to re-assign workflow tasks in SharePoint.


SharePoint by default only allows the assignee to re-assign the task. If you try to re-assign a task that is not assigned to you, you get the following message:

Task update was not accepted. To edit a task associated with a workflow task process, you must be the person to whom the task is currently assigned.


To overwrite this behaviour:

  1. Open SharePoint Designer
  2. Open the Workflow you wish to modify.
  3. On the step where you start the workflow task ‘Start <workflow task name> process on Current Item with…’, right click on the task name.
  4. Select Properties and look for the attribute TaskProcessOwner.
  5. Click on the ‘‘ button to select a group or specific user.
  6. You may wish to create a SharePoint group specifically for this purpose. All members of this group will have permissions to re-assign tasks that are assigned to other people.

Comments ( 2 )

Start a workflow using PowerShell


Start a workflow on all / specific items in a list.

Change the site and workflow names to suit your requirements. I included a condition in this script to only start the workflow on items where ‘Status’ is not equal to Complete. You can remove this condition if you wish to run the script on all items in the list.


Use a PowerShell script to start the workflow.

#Site and List  
$SPAssignment = Start-SPAssignment 
$web = Get-SPWeb "http://your-site" -AssignmentCollection $spAssignment 
$site = Get-SPSite "http://webservices.rcrtom.com.au"
$listToCancel = "your-list";
$web.AllowUnsafeUpdates = $true;
#Output file
$Today = Get-Date -Format "dd-M-yy"
$outFile = "c:\CancelWorkflowScript-Log-$Today.txt"
#Workflows to Remove
$wfToStart= "Name of workflow"
#List Name  
$list = $web.Lists[$listToCancel]; 
#Workflow Manager
$association=$list.WorkFlowAssociations | where {$_.Name -eq $wfToStart}
$association.AllowAsyncManualStart = $true
$association.AllowManual = $true
# Iterate through all Items in List and all Workflows on Items.  
	#Filtered List
	Write-Host "Restarting workflows.."
	foreach ($item in $list.Items) { 
		if ($item["Status"] -ne "Completed") {
			Write-Output "$wftoStart started on " $item.Name | Out-File $outFile -Append
		else {
			Write-Output $item.Name " - is completed " | Out-File $outFile -Append
Write-Host Finished.

Note: Workflows started using via PowerShell like this do not trigger other workflows when they complete, even if you have other workflows set to automatically start on item change.

Comments ( 3 )

Open Workflow Initiation form after InfoPath form submit


After users complete an InfoPath web browser form, we want the user to be redirected to the approval workflow initiation form after the InfoPath form closes. We could not use the option to start the workflow on item creation as we needed to user to select an approver or multiple approvers.


We managed to get this working by creating a page with an InfoPath form webpart and a data view web part. The InfoPath form sends a configured set of parameters to the dataview webpart upon submission. The dataview webpart is then configured with a HTTP redirect so that it opens the workflow initiation form as soon as it receives data from the InfoPath form.

Configure your InfoPath form submit rule

  1. Select your submit button -> Manage Rules
  2. Ensure that ‘Send data to web part’ is set after ‘Submit using a data connection’.


Configure the Form Parameters

  1. Open your InfoPath form -> File -> Form Options
  2. Under Property Promotion, add at least one property to identify each item in the list. You may add additional items if you wish to do filtering.
  3. Click on OK and Publish your form when done.

Creating a new page and add the InfoPath form and Dataview Webparts.

  1. Open SharePoint Designer 2010 -> Site Pages -> New Page.
  2. Add an InfoPath form webpart and link it to your form.
  3. Add a dataview webpart and link it to your form library.

Configure the Dataview webpart

This webpart is simply used to get data from the InfoPath form, build the URL to the workflow initiation form, and redirect the user to it. After configuring the webpart, you should set its status to hidden.

  1. Select your dataview webpart -> Options (on the ribbon) -> Add/Remove Columns
  2. I selected only the ‘Name’ column as this webpart is going to be hidden anyway.
  3. Under Parameters (on the ribbon), add your filter attribute and unique identifier. In my case, I used ‘RequestNo’ to uniquely identify each record, and ‘RecruitChoice’ as a filter.
  4. With your parameters set up, click on Manage Connections (on the ribbon).
  5. Add a new connection with action ‘Get Parameters from’.
  6. Select ‘Connect to a Web Part on this page’ -> Target Web Part: InfoPath Form Web Part
  7. Target action: Send Data To
  8. Map the parameters in the InfoPath form to the parameters you set up in the dataview webpart.
  9. Click finish

Dataview Parameters


Webpart Connection

The next thing you need to do is set up a filter on the Dataview Webpart.

  1. Select the Dataview Webpart -> Filter (on the ribbon)
  2. Map the promoted property from your InfoPath form (in my case it is RequestNo) to the parameter you created for the DVWP ([RequestNo])
  3. Click OK.

Modify the Dataview Webpart’s XSL template

On the same page, switch your view to Code view (if you haven’t already done so).

Look for the line that says:

<xsl:template name=”dvt_1.rowview”>




Replace its entire contents with the following code, changing the parts in blue to suit your environment and requirements.

Note: In my case, I wanted to start seperate workflows depending on whether RecruitChoice = ‘staff’ or ‘workforce’.

<xsl:template name=”dvt_1.rowview”>
<xsl:if test=”contains($RecruitChoice, ‘staff’)”>
<meta http-equiv=”refresh” content=”0;url=http://sharepoint/_layouts/IniWrkflIP.aspx?List=c4ea0309-8025-4997-a438-1b9b2443ba8b&amp;ID={@ID}&amp;TemplateID=7d892fbe-052d-4c53-9f73-b7347c5364e5“/>
<xsl:if test=”contains($RecruitChoice, ‘workforce’)”>
<meta http-equiv=”refresh” content=”0;url=http://sharepoint/_layouts/IniWrkflIP.aspx?List=c4ea0309-8025-4997-a438-1b9b2443ba8b&amp;ID={@ID}&amp;TemplateID=253f428b-e505-4dc3-87f1-954d3a5adbfc“/>

Save the page and test the form.

If you have configured everything correctly, save the page and open it in the browser.

Complete the form and test with the parameters you specified earlier.

Your form should automatically direct to the workflow initiation form after you click the ‘Submit’ button.

Things to note

  1. Since the URL of the workflow initiation form is hardcoded, if you globally re-republish your workflow, you will need to update the TemplateID of the workflow.



Comments ( 0 )

Cancel previous version workflows in a list and restart new ones using Powershell


You have multiple running workflows in a list either in ‘pause’ or ‘wait for item change’. You make a modification to the workflow and publish again. All existing running workflows become ‘workflow name (previous version: date – time). The next time someone updates the list item, you end up with 2 running workflows. This can be problematic if the workflows are used for notification. For example, the user ends up with 2 notification e-mails.


You need to find a way to safely cancel all existing workflows and start the new ones. Note, I have checks / conditions in my workflows so that all the restarted workflows pause / wait at the same state as before. This may not be the case for you, so it is best to run this script in a test environment first.

This script will:

  • Look for a particular list in a site/subsite.
  • Go through all items in the list
  • Go through all workflows in each item
  • Cancel workflows with names matching ‘wftocancel’.
  • Go through the same list
  • Look for all items with the field ‘Verified’ = ‘Completed’.
  • Start the workflow with name matching ‘wftostart’.

Here is the script, update the lines in bold as required.

If you found this helpful, please like my post. Thank you!

#Site and List
$web = Get-SPWeb http://sitename;
$site = Get-SPSite "http://sitecollection"
$listToCancel = "Listname";
$web.AllowUnsafeUpdates = $true;
#Workflows to Remove
$WfToCancel = "Workflow name (previous version...)";
$wfToStart= "Workflow name"
#List Name
$list = $web.Lists[$listToCancel];
#Workflow Manager
$association=$list.WorkFlowAssociations | where {$_.Name -eq $wfToStart}
# Iterate through all Items in List and all Workflows on Items.
foreach ($item in $list.Items) {
foreach ($wf in $item.Workflows) {
#Test for workflow complete and match criteria
if (($wf.ParentAssociation.Name -eq $wfToCancel) -and ($wf.IsCompleted -ne $true))        {
#Show status and cancel Workflows
write-Host $wf.ItemName -nonewline;
write-host "     " -nonewline;
write-host $wf.ParentAssociation.InternalName;
Write-Host " Status " -nonewline;
Write-host $wf.InternalState;
#Filtered List
foreach ($item in $list.Items) {
if ($item["Verified"] -ne "Completed") {
Write-Host "$wftoStart started on " $item.Name
else {
Write-Host $item.Name " - no action taken"

Comments ( 1 )