SP 2013 Workflow - Find Max ID of List

Kelly Taggart 216 Reputation points
2021-09-09T23:59:19.41+00:00

I am creating an SP 2013 Workflow with a "Loop" step to delete other list items. This works as I would expect.

Multiple items will be created at the same time (created from submitting a form from another library) so I only want the "Loop" step to run on the item with the Max ID. So, I was going to create an IF Condition of - IF Current Item ID = Max ID in List - then run the Loop otherwise go to next Stage.

I'm struggling with a way to identify in the Workflow what is the current Max ID? Any ideas?

SharePoint Workflow
SharePoint Workflow
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Workflow: An orchestrated and repeatable pattern of business activity, enabling data transformation, service provision, and information retrieval.
541 questions
0 comments No comments
{count} votes

Accepted answer
  1. Kelly Taggart 216 Reputation points
    2021-09-15T05:38:24.203+00:00

    Hi @Allen Xu_MSFT - I did look at that post and I know Laura does some pretty good stuff. For what I was after I thought it just looked like too much work.

    What I did do in the end was in InfoPath form that submits the list items, I added an Action Rule to the Submit button to "Set Field Value" of a Text Column to "max(ID)+1 and Queried this Data Connection of the List.

    Then in the workflow, I added an Action of "IF Current Item ID=MaxID (from above), run the Loop on this item. Seemed to the trick.

    Thanks for pointing me in the right direction though!

    132209-image.png

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Allen Xu_MSFT 13,796 Reputation points
    2021-09-10T07:07:32.03+00:00

    Hi @Kelly Taggart ,

    To loop through multiple SharePoint list items in the workflow, you can use Call HTTP Web Servcie action. Below article covers how to loop through list items, please take a refernence to it: WORKFLOW LOOP THROUGH MULTIPLE SHAREPOINT ITEMS.

    Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.