SharePoint 2013 Workflow: Check if list item exists

For a customer we are building a complex approval process on Office 365 with SharePoint 2013 workflows. During the process we need to check if an list item (in an other list) existed. There is no default action that lets you do this. You can however us the set variable and if statement action to figure out if the item you are looking for exists or not. This is a useful trick to know when working with SharePoint 2013 workflows.

Solution

  1. Create a SharePoint 2013 workflow.
  2. Create a  variable called ContractItemID, here we will try to store the ID of the list item we are trying to find.
  3. Set the variable to 0 (zero).
  4. Then we need to try and set the ContractItemID variable with the ContractID of the item we are searching. This can be from the same list or a different list.
  5. I am trying to find the ID of a list item with a specific Contract Number.
  6. If the workflow finds an ID the ID will be stored in the variable, if no item is found then the ContractItemID value will remain 0 (zero)
  7. Use an if statement to determine if the list item exists.

 

Share

13 Replies to “SharePoint 2013 Workflow: Check if list item exists”

  1. Thank you very much for your post! I am working on SPD workflow, and it is suppose to create and if it exists update an item in another list. I was able to achieve both but when it updates, it duplicates. The workflow starts when an item is created and item is changed. How can I prevent it from duplicating. Please help

  2. Hi Ben,

    Thanks for your response.
    I have two lists List1 with columns(Title,Author…) and List2 with columns(Title, Author). When I create a new item in List1, it copys the item using workflow from List1 to List2 (using Create item in this list (Output to Variable: create)), which is working fine but when I update an item in List1, it updates the matching item in List2 and creates another entry in List2 using(Update item in this list). I am trying to copy items from List1 to List2 and if I make any change to one of the columns(Title, Author) in List1 items then it should modify items in List2 columns(Title, Author).

    Thank you for your help.

  3. A possible solution is to create two workflows. One that start on when a new item is created and that created the item in list number 2. Then a second workflow that starts on update, that workflow then updates the related item in list 2.

  4. I was thinking to do ‘call HTTP service’ and count the no: of item through rest. But, this one is a lot easy. Thanks. 🙂

  5. I’m not sure if you still monitor this – but my list has over 5000 items and it seems that when I check if the item exists, it throws an error when it doesn’t exist : The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator. It works fine if the item does exist.
    So I’ve been trying for a while now to prevent this error but not successful. including this one.
    Any thoughts would be appreciated.

Leave a Reply

Your email address will not be published. Required fields are marked *