locked
Looping Workflows and dealing with missing list items RRS feed

  • Question

  • I've been using this blog article to create a looping series of workflows to update items when necessary. Initially I used a counter variable (iCounter = iCounter +1 in the next iteration) to move through a list. However, this does not take into consideration when someone has deleted an item and so there is a gap in the sequential numbering.

    Is there a way to test for an item's existence and move the counter forward prior to committing to having the workflow look up a list item? I don't see a way of trapping the error and avoiding the workflow crashing once it has attempted a lookup and returned the list item not found error.

    I've got a request in to our IT department to have Visual Studio and the Sharepoint Server SDK extensions loaded to my machine, but for now I'm restricted to out-of-the-box Sharepoint Designer workflow functionality. But I need something that will function for the time being prior to the time it will take them to get to that request.

    Kind regards,

    Bruce

    Tuesday, June 12, 2012 9:50 PM

All replies

  • Hi UNCBearBruce,

    Thank you for your question.
    I am trying to involve someone familiar with this topic to further look at this issue.

    Thanks,
    Lhan Han
    Friday, June 15, 2012 8:28 AM
    Moderator
  • Thank you, Lhan. I appreciate your efforts.
    Friday, June 15, 2012 2:26 PM
  • Hello Bruce,

    One option I can think of is to send request to a user and let user check the existence of an item, depending the answer from user, you can let workflow do different actions.

    Other than that, there is no OOB action can check existence of a list item.

    Regards,

    Jing Wang | Microsoft Online Community Support


    Wednesday, June 27, 2012 2:13 PM
  • I'm unmarking this as answered because while it is an explanation that Microsoft did not adequately consider and program for this condition, it does not provide a true answer for how to approach it in an automated fashion. Having a user monitor a large list in order for an automated process to correctly process is not a practical answer. 
    Thursday, July 5, 2012 2:22 PM
  • I found using following logic, you can find if certain list item exist without crashing workflow:

    Set Varible:Exist to Yes

    then set Varible:Exist to clist:ID (this is a lookup, ID = some value, if the item exists "Exist" will be the ID of that item, if not, "Exist" will be 0)

    If Varible:Exist equals 0

     Log Item with ID(some value) does not exist

    Else
     
     Log Varible:Exist

    I hope above helps.

    Regards,

    Jing Wang | Microsoft Online Community Support

    Friday, July 13, 2012 3:59 PM
  • Thank you for your suggestion; I really do appreciate your efforts to help.

    I can't get this to work as you describe, though, as I can't get it to move to the next list item to set the "Exists" flag without the workflow attempting to find the item and then crashing. Or maybe I'm not following from your description how you're setting the Exists flag.

    Another suggestion from another group seems to work, though it also requires some manual intervention (one time set up for each item that is inadvertently deleted) -- have another list that you restrict from users where you categorize the items in the original list of interest as valid or not. So:

    • Create another list with restricted rights so typical user can't accidentally delete things from it and recreate the problem.
    • The columns are ID, number field to represent the ID from the original list, Boolean field default to Yes that original list item is valid.
    • Have a workflow automatically add an item to this list when a new item is added to the original list.
    • When an item is accidentally deleted from the original list and causes a workflow crash, manually go into this reference list and set the Valid Boolean flag to No.
    • Modify the looping workflow to reference this list and skip any items where the Valid flag is No.

    Since it involves yet another list to cobble together an imitation looping function, it is not the most elegant of solutions (I'd prefer to get something like you suggest to work since it would involve only the original lists). But it appears to work in my situation.

    I hope this helps anyone else facing a similar problem.

    Wednesday, July 18, 2012 12:28 AM