how to compare two list items and delete based on a condition

Jan 5, 2012 at 3:19 AM

I am trying to use SPServices to query against a list that has fieldA and FieldB common then i need to delete the record that has the created date earlier. Example if task A and B have same value for fieldA and fieldB then the created dates are compared and the one with an earlier date needs to be deleted.

Jan 5, 2012 at 3:29 PM
Edited Jan 8, 2012 at 10:03 PM

You can certainly build something like this using SPServices. You'd use GetListItems to get the items from the list and then spin through all of the items which meet your criteria. If the condition is met, then delete the appropriate item with UpdateListItems.


Jan 8, 2012 at 7:12 PM
Hi there,

An example will be much appreciated. I am completely new to this. I would like to do something like

If (item1.columnA==item2.columnA)
Then delete item1.

Pls note: both items are in same list. This query is to delete a certain type of duplicates based on some condition.


Jan 8, 2012 at 10:04 PM


There are plenty of examples he or on my blog which should get you started. Once you have some code to share, post back with questions.