?
Solved

How to cancel multiple 'Error Occurred' workflows within a single list in SharePoint 2010

Posted on 2013-05-28
5
Medium Priority
?
4,274 Views
Last Modified: 2014-09-25
In our QA environment we have several workflows that have not completed due to errors. There are several thousand workflows in 'Workflow In Progress' status. We would like to cancel all the workflows that have errored out and are still in progress from only within this specific list. I've attempted running a powershell script but I could not get it to work.

Does anyone have a way or script to remove these failed instances?
0
Comment
Question by:macarrillo1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 42

Accepted Solution

by:
sedgwick earned 1000 total points
ID: 39203704
here's the workflow status code list:
http://www.vadimtabakman.com/nintex-workflow-powershell-workflow-status-codes.aspx

this code run through all workflows in some list, and cancel those who got status
3 or 7 (error occur):

#Site URL
$web = Get-SPWeb "http://urlforsite.com";
$web.AllowUnsafeUpdates = $true;    

#List Name
$list = $web.Lists["ListName"];

# Iterate through all Items in List and all Workflows on Items.         
foreach ($item in $list.Items) {
foreach ($wf in $item.Workflows) {
if($wf.InternalState -match 'Error')
{
#Cancel Workflows        
[Microsoft.SharePoint.Workflow.SPWorkflowManager]::CancelWorkflow($wf);      
}
}
}
$web.Dispose();

Open in new window


from http://stackoverflow.com/questions/7595256/cancel-multiple-sharepoint-workflows-using-powershell
0
 
LVL 9

Author Comment

by:macarrillo1
ID: 39208394
Thank you sedgwick,

We wanted to run the status script before we ran the Workflows script to determine the status errors. As I ran the status script, I came across an error message when I enter the name of the workflow- we receive 'You cannot call a method on a null-valued expression.

Am I doing something wrong?

If more information helps, we have a workflow with multiple versions-when prompted for the Workflow name via the script, are we to only use the name of the WF or are we to list each version of the workflow?
0
 
LVL 70

Expert Comment

by:Qlemo
ID: 40344671
I've requested that this question be deleted for the following reason:

The question has either no comments or not enough useful information to be called an "answer".
0
 
LVL 9

Author Closing Comment

by:macarrillo1
ID: 40344672
This is very helpful, but need more information to work out a complete solution.
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There is a massive demand for content on the web right now, and it doesn't look like it's going to stop any time soon. But, if you are running a business blog, it's not just enough to offer your audience lots of content. It needs to be high-quality…
In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question