0

I want to archive a large list (list 1), therefore i saved template of that list without content and renamed it (list 2) and created brand new empty list off that template. Now i am using if statement to compare status of the list item(list 1) as closed. if the condition is met i am copying list item into List 2 and pausing the workflow for 1 minute and delete that item of the list 1.

i have set the workflow to fire off manually.

I have about 5000 items on the list, I cant sit all day and trigger workflow off each item manually. Is there a way i can use this workflow to go across all items on the list and do its job automatically.

Any suggestion would be appreciated.

Thank you

1 Answer 1

0

You can usePowerShell to run workflow on all items. The Workflow will not start instantly (as opposed to triggering through the UI) but in maximum 5 minutes because it's started through the SharePoint Timer Service.

# URL of the Site
$web = Get-SPWeb -Identity "https://sharepointsrv/site1"

$manager = $web.Site.WorkFlowManager

# Name of the list
$list = $web.Lists["Shared Documents"]

# Name of the Workflow
$assoc = $list.WorkflowAssociations.GetAssociationByName("On Item Created","en-US")

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

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

http://social.technet.microsoft.com/Forums/sharepoint/en-US/dffdceab-f2fe-4886-8e2a-ea26cf08c78a/how-to-start-a-speific-workflow-programatically-in-sharepoint-2010-via-powershell

http://gallery.technet.microsoft.com/office/Start-a-Workflow-on-120bffe5

10
  • thank you for your response, What items needs to be changed in the powershell for my workflow lets call it( Aanchal) to trigger automatically. Commented Sep 23, 2014 at 15:39
  • I am not able to understand your query.
    – Aanchal
    Commented Sep 23, 2014 at 15:41
  • What do i need to change in above powershell for it to work on my case. Commented Sep 23, 2014 at 15:43
  • Changr site url, document library name and workflow name. Do test it on dev server before running this on prod
    – Aanchal
    Commented Sep 23, 2014 at 15:45
  • Do i need to change the settings to actual workflow which is currently set to trigger manually? Commented Sep 23, 2014 at 15:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.