This project has moved and is read-only. For the latest updates, please go here.

Duplicate entries in GetListItems

May 30, 2012 at 3:31 PM

I'm using the GetListItems operation to fetch some data from a list to append to a table.  I'm getting duplicates and triplicates in my output and I don't know why.  I built and tested the CAML query with U2U and it successfuly pulls back my data without duplicates so there has to be an issue with my code somewhere I'm just not seeing. 

Using jQuery 1.5.1 and SPServices 0.6.1 in this site collection.

The function that paints my list:

    operation: "GetListItems",
    async: false,
    listName: "Courses",
    CAMLQuery: "<Query><Where><Geq><FieldRef Name='StartDate' /><Value IncludeTimeValue='TRUE' Type='DateTime'><Today /></Value></Geq></Where><OrderBy><FieldRef Name='Title' Ascending='TRUE' /><FieldRef Name='StartDate' Ascending='TRUE' /></OrderBy></Query>",
    CAMLViewFields: "<ViewFields><FieldRef Name='ID' /><FieldRef Name='Title' /><FieldRef Name='FilledSeats' /><FieldRef Name='StartDate' /></ViewFields>",
    completefunc: function (xData, Status) {
      $(xData.responseXML).find("[nodeName='z:row']").each(function() {
       var cID = $(this).attr("ows_ID").replace(/\..*/g, "");
       var cTitle = $(this).attr("ows_Title");
       var seats = $(this).attr("ows_FilledSeats").replace(/\..*/g, "");
       var cstart = formatYear($(this).attr("ows_StartDate"));
       var chtml = "<tr><td onclick='javascript:seeData(" + cID + ");'>" + cTitle +"</td><td>"+ seats +"</td><td>"+ cstart +"</td></tr>";

May 30, 2012 at 4:18 PM

It's definately something with my CAMLViewFields, commenting that out it works fine. See anything out of place there?

May 30, 2012 at 4:43 PM

The CAML appears correct.  Can you modify your <ViewFields> to *not* use the Title and ID fields?




May 30, 2012 at 4:56 PM

That still results in duplicate values.  I'm just going to proceed on as it returns all the data I need without specifying the CAMLViewFields.

May 30, 2012 at 9:46 PM


Didn't you have some sort of duplication thing going on a few weeks back? Someone did, but I can't remember if it was you.

The first thing I would so is put an alert at the top of the completefunc to see what the raw XML conming back looks like:


If there aren't duplicates in the XML, then it's your script. If there *are* duplicates in the XML, then something is happening on the server side, either oddities or based on your CAMLQuery.


Jun 1, 2012 at 7:55 PM

I have seen this in one occasion and was never able to get a solution other than custom client side code to remove it.
In my case I narrowed it down to a row that had multiple users selected (column was of type 'people and groups' and allow multiples was set for it). For that one row, SharePoint was returning duplicate rows (same ID duplicated on multiple rows; one row for each user that was set)... If I removed the column from the query, issue went away.
Again, never go to the bottom of that one. Let us know if that might also be your root cause.

I'll also check my notes , once I'm back at the office, to see if I have any other information


Sent from mobile

Jun 2, 2012 at 5:42 AM

There's a new item in the Issue Tracker that's similar. Now that I have that example, I seem to fuzzily remember running into this in the distant past. I'm going to look into that item, so maybe I'll have some insights. You might want to watch it.


Jun 25, 2012 at 9:14 PM

Try addin this to the call

CAMLQueryOptions: "<QueryOptions><IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns><DateInUtc>TRUE</DateInUtc></QueryOptions>"


I've read some poststhat say you get duplicates if there is a required lookup column that allows multiple values  I'm trying myself to get the multiple rowss to be returned so i can group my lview by the multi-select field, but i can't get it to return the dulplicates.