none
Sharepoint Workflow on Mutliple items / Entire list RRS feed

  • Question

  • Hi

    usually workflow run on current Item. Can I run workflow manually on entire list? Scenerio is as follows:

    I have two columns in List i.e. Status and Comment. In few items Status is Close whereas in few other items it is Open.

    I want that workflow should run on entire list and check the status in each item. Where it get Close status, a value has been set to other field "Comment" i.e. "Ready to archive.

    what workflow code I can use to perform  this task?

    Sunday, February 10, 2019 7:20 PM

All replies

  • Hi 

    You can create Site Workflow in SharePoint.

    It can update many list items when it's running.

    And you can start the site workflow by powershell and task schedule.

    https://www.mssqltips.com/sqlservertip/3932/run-a-site-workflow-with-powershell-and-the-windows-task-scheduler/

    https://prairiedeveloper.com/2017/02/start-sharepoint-2013-workflows-with-powershell/


    Please remember to mark the replies as answers if they helped.
    Linyu - SharePoint Engineer
    QQ Group: 72637444

    Monday, February 11, 2019 2:22 AM
  • Hi Aquarian,

    You could create a SharePoint 2010 platform workflow to check the Status field value, if it is Close, then update the Comment field:

    Then publish the workflow, you could trigger the workflow in the list for all items using PowerShell or manually.

    For SharePoint 2010 workflow platform, use this PowerShell to start workflow for all list items in a list:

    # URL of the Site
    $web = Get-SPWeb -Identity "http://sp"
     
    $manager = $web.Site.WorkFlowManager
     
    # Name of the list
    $list = $web.Lists["DemoList"]
     
    # Name of the Workflow
    $assoc = $list.WorkflowAssociations.GetAssociationByName("testwf10","en-US")
     
    $data = $assoc.AssociationData
    $items = $list.Items
    foreach($item in $items)
     {
     $wf = $manager.StartWorkFlow($item,$assoc,$data,$true)
     }
      
    $manager.Dispose()
    $web.Dispose()

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Monday, February 11, 2019 7:11 AM
  • Can't I do it without using powershell? I tried workflow above but it run on single item at a time. I want that a workflow run once a day and it makes change to all the items (reccords) where condition met.

    Monday, February 11, 2019 6:30 PM
  • Hi,

    Actually, this reqirement not need to use workflow achieve.

    As you want to run once a day to check the "Close" items and then set Comment field, you could write a PowerShell script to update the items and then use Task Scheduler to trigger the PowerShell script:

    $web = Get-SPWeb http://sp/
    $list = $web.Lists["DemoList"]
    foreach ($item in $list.Items)
    {
      if($item["Status"] -eq 'Close')
      {
        $item["Comments"] = "Ready to archive";
        
        $item.Update();
      }
    }

    How to Run a SharePoint PowerShell Script From Task Scheduler

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Tuesday, February 12, 2019 4:19 AM
  • Hi,

    you <g class="gr_ gr_7 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="7" id="7">careate</g> <g class="gr_ gr_8 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="8" id="8">sharepoint</g> designer list workflow and make settings to run on item modify,

    So workflow will run on <g class="gr_ gr_10 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" data-gr-id="10" id="10">everytime</g> when <g class="gr_ gr_9 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar only-ins doubleReplace replaceWithoutSep" data-gr-id="9" id="9">item</g> has been modified,

    add the action to update the same item comments column

    https://docs.microsoft.com/en-us/sharepoint/dev/general-development/creating-a-workflow-by-using-sharepoint-designer-and-the-sharepoint-wo


    Karim... Please remember to mark your question as answered, if this solves your problem.

    Tuesday, February 12, 2019 4:46 AM
  • Hi,

    you careate sharepoint designer list workflow and make settings to run on item modify,

    So workflow will run on everytime when item has been modified,

    add the action to update the same item comments column

    https://docs.microsoft.com/en-us/sharepoint/dev/general-development/creating-a-workflow-by-using-sharepoint-designer-and-the-sharepoint-wo

    Karim... Please remember to mark your question as answered, if this solves your problem.

    Tuesday, February 12, 2019 4:47 AM
  • Hi,

     

    I am checking to see how things are going there on this issue. Please let us know if you would like further assistance.

     

    You can mark the helpful post as answer to help other community members find the helpful information quickly.

     

    Thanks

     

    Best Regards


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Friday, February 15, 2019 2:50 AM