79408

How to perform Looping Through List Items in SharePoint 2013 Designer Workflows?

Question:

I am new to SharePoint. I'm creating a workflow in SharePoint 2013 in which I want to iterate a List using a loop. How to perform looping through list items in SharePoint 2013 Designer Workflows?

Answer1:

I'm not aware that there's any out-of-box way to get a workflow to "loop through" all entries in a list, but you can try to make two workflows bouncing back to each other until all entries are updated, here is the detailed steps,

<ol><li>

assuming that the list that we are working on is named list_work, in this list, create a column named e.g. cargo

</li> <li>

define another list, name it e.g. list_control,

<ul><li>define a column named e.g. listID,</li> <li>define a column named e.g. cargo, </li> <li>create one entry in the list, set the cargo to a value. </li> </ul></li> <li>

define a workflow, name it e.g. workflow_list_control, which is triggered every time the entry in list_control is updated, and in this workflow,

<ul><li>search for an entry in the list_work where the list_work.cargo doesn't equal list_control.cargo</li> <li>if any entry is found, update the entry of list_work and set the list_work.cargo with list_control.cargo, in order to trigger the workflow_list_work (see #4 below)</li> <li>if no entry is found, stop this workflow. </li> </ul></li> <li>

define the workflow that needs to be run on the list_work, e.g. named workflow_list_work, make it's triggered every time the entry in list_work is updated, and in this workflow, make sure it updates the only entry in the list_control with the ID of the entry from list_work that is being modified, only to trigger the workflow_list_control. In this step, try to put a workflow step to wait and verify the ID is properly updated, in order to allow enough time for the previous workflow_list_control properly finishes.

</li> </ol>

Every time if a looping-through is necessary, modify the entry in list_control with a different value in the cargo field.

Also refer to <a href="https://sharepoint.stackexchange.com/questions/101125/calculated-column-to-retrieve-total-number-of-id" rel="nofollow">calculated-column-to-retrieve-total-number-of-id</a>

Answer2:

You can do this in SharePoint 2013 (ONLY!) using the new "HTTP web service". The "trick" is to create a task that will call the HTTP Web Service and call ".../client.svc/web/lists/getbyid(<List Guid>)/items". Return the (JSON) results in a (new in 2013 also!) "dictionary" variable. Then use the "Get an Item from a Dictionary" action and "item by name or path" and enter "d/results", select the "dictionary" variable (that you captured the results in) and output to another dictionary variable (call it "data"). Then get the count (for the loop) by using the action "Count Items in data" and output that to a variable (totalItems) to get the number of records. For the "loop" you will use the "Loop with condition". Use a variable called "index" and set it to 0, then "Loop with condition" until "index < totalItems". In the body of the loop, the first thing you will do is "Get an item from a dictionary" use "item by name or path" and using string builder "d/results/(<index>)/". The "Column Name to Retrieve" will be whatever column(s) you want to evaluate (like maybe "DueDate"). (Note: You will have to use the "Static Name" of the column, which can be found by going to the Task List Settings and clicking the name of the column, then in the URL find the "Field=<Name>" portion.. It is that "<Name>" that you will use.)

I know this is very CRUDE maybe even bordering on "useless" for alot of users, but I felt I should at least attempt a quick reply. When I have more time, I will try to edit this and format my reply better. Although, I found this because of a similar need and since I figured out a way to accomplish what I was needing, I felt compelled to at least share it the best I could, in the limited time I had available. ;) So, maybe SOMEONE will find what I have attempted to describe, "useful". :)

Recommend

  • cannot load gems in test environment
  • Install different versions of nuget packages inside one solution file with two projects
  • Paramiko SSHException Channel Closed
  • reduce/reduce conflicts using ocamlyacc
  • How to write string.Contains(someText) in expression Tree
  • How to get the index of element in the List in c#
  • Rails AREL .where statement
  • Parallel sieve of Eratosthenes - Java Multithreading
  • goJS dropdown remove items
  • php show all images in directory and sort by last modified
  • Manually Timing out a C# Thread
  • EF 4.1 DBContext AutoDetectChangesEnabled
  • Regex for nested values
  • Jenkins Grails plugin does not list lastest versions of Grails
  • Aptana 3 remove bundle (jquery)
  • How can I tell a form not to dispose a particular control when it closes?
  • Multiple producers single consumer locking schema
  • SonarQube: Cannot deactivate rule with missing quality profile
  • Debugging VB6 Code From Visual Studio 2010
  • Diff between two dataframes in pandas
  • Code in Job's Script Block after Start-Process Does not Execute
  • Email verification using google app script and google forms
  • MailKit: The IMAP server replied to the 'EXAMINE' command with a 'BAD' response
  • Java: can you cast Class into a specific interface?
  • AES padding and writing the ciphertext to a disk file
  • How to add a column to a Pandas dataframe made of arrays of the n-preceding values of another column
  • Updating server-side rendering client-side
  • How to extract text from Word files using C#?
  • Trying to switch camera back to front but getting exception
  • SVN: Merging two branches together
  • RestKit - RKRequestDelegate does not exist
  • Hibernate gives error error as “Access to DialectResolutionInfo cannot be null when 'hibernate.
  • VB.net deserialize, JSON Conversion from type 'Dictionary(Of String,Object)' to type '
  • using conditional logic : check if record exists; if it does, update it, if not, create it
  • How to delete a row from a dynamic generate table using jquery?
  • json Serialization in asp
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • How to stop GridView from loading again when I press back button?
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?