I`ve created a workflow from SPD2013 for SPS2013 List, that will delete the list item based on closing date equals to today. Issue, it does it for the only one item, even though if there are more than 1 item with closing date set to today. I understand workflow suggest for incase of multiple items, it will do it for the first. Please suggest if any option to perform delete option for multiple items at once?
2 Answers
You can set up retention policy to start a workflow when any condition (in your case closing data is today) is satisfied. In that workflow you can set step to delete the item. This way multiple items can trigger workflow to do the required functionality.
-
thanks but if I want to in future to perform delete and archive, I guess would be an issue?– JasonCommented May 30, 2016 at 6:26
-
You are asking about the archiving the item ? In workflow you can do anything as per your functionality. Commented May 30, 2016 at 6:28
-
I understand in workflow u can do anything, but not sure how can I achieve to have all items copied and later deleted if the closing date is of Today?– JasonCommented Jun 1, 2016 at 1:45
-
I got the solution, created a workflow and set it run on all items every night to do the following. Check workflow Screenshot -
https://i.sstatic.net/MKowj.jpg
In order to run daily on all items and not just current item (usually workflow will run on one item at a time) -
Powershell Code
`# URL of the Site
$web = Get-SPWeb -Identity "example.com"
$manager = $web.Site.WorkFlowManager
# Name of the list
$list = $web.Lists["List name"]
# Name of the Workflow
$assoc = $list.WorkflowAssociations.GetAssociationByName("Workflow name","en-US")
$data = $assoc.AssociationData
$items = $list.Items
foreach($item in $items)
{
$wf = $manager.StartWorkFlow($item,$assoc,$data,$true)
}
$manager.Dispose()
$web.Dispose()