0

Trying to delete old items on new item creation. I have followed the steps here: Delete old Item with new Item using SharePoint Designer Workflow

This works but it deletes the first occurrence where the title is the same. I need it to only delete if it was created by the same user. Whenever I add another condition of user name it does not work. I have it like the following: enter image description here

Why does this not delete with the additional condition of employee name also being the same?

2

The default SPD Workflow lookup is limited to 1 comparison criteria of type FieldName = Value, and returns the first item that matches. What you need to do is match on two fields: Title and Author. This is not possible via this method.

You will have to fetch your items by using an HTTP call to access the REST API. This is ... complicated, especially the first time you try it. Here is a good primer:

https://cann0nf0dder.wordpress.com/2017/06/25/sharepoint-designer-2013-workflows-and-get-rest-api/

In addition to the basic methodology listed here, you'll need to filter the results to bring back only the items that match Title and Author. Again, a short primer:

https://social.technet.microsoft.com/wiki/contents/articles/35796.sharepoint-2013-using-rest-api-for-selecting-filtering-sorting-and-pagination-in-sharepoint-list.aspx

Your final URL will look something like this:

[%URL of Current Site%]/_api/lists/getByTitle('Your List Name')/items?$filter=(Author eq [%current item:Author%]) and (Title eq [%current item:Title%])&$select=ID

0

Are you using SharePoint 2010 or SharePoint 2013?

If you are using SharePoint 2010, there is no way to delete all matched items via workflow. If you are using SharePoint 2013 or later edition, you can use SharePoint 2013 platform workflow with "Call HTTP web service" to retrieve the matched list items and loop each one and delete it.

To use SharePoint 2013 platform workflow in SharePoint 2013 or later edition, you need to install and configure Workflow Manager for your SharePoint farm.

There are some articles for your reference:
Workflow Manager Configuration For SharePoint Server 2013

Looping Through List Items in SharePoint 2013 Designer Workflows

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.