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

CAML returns duplicate results

Jun 22, 2011 at 2:01 PM

Let me start out by saying I am new to SharePoint and have only a little JavaScript/JQuery experience.  I'm trying to utilize Marc's great library to surface a dynamic list of executive blog post links to a page with their Bio.  Our customer has very specific requirements when it comes to the look and feel of this page and the Content Query webpart wasn't cutting it.  So I wrote the script below which was working great except when the executive category field was changed to multi-value.  Now if more then one executive is listed it duplicates the results.  For example, if Joe and Mary are listed as the execs, the blog post title is returned twice.  I've used the U2U Caml builder and get the correct results back (no duplicates).  I've also tried changing the Type from LookupMulti to Text and from Contains to Equal, same result.   One last thing, we are using the BPOS (online) 2007 version.  Thanks in advance for any help you can give... (find the script below...)

<script language="javascript" type="text/javascript" src="server/Global/ScriptLib/jquery-1.6.min.js"></script>
<script language="javascript" type="text/javascript" src="server/Global/ScriptLib/jquery.SPServices-0.6.0.min.js"></script>
<script language="javascript" type="text/javascript">

var execFld='PostCategory';
var listID= '{xxxxxx-ffea-44c0-9e47-d4894aac2bb8}';

function execPull(execValue,hideDiv,showDiv) {
$(document).ready(function() {
          operation: "GetListItems",
            async: true,
            listName: listID,
            CAMLQuery: '<Query>'+
         '<FieldRef Name=\''+execFld + '\'/>'  +
         '<Value Type=\'LookupMulti\'>' + execValue +'</Value>'+
            CAMLViewFields: "<ViewFields>"+
         "<FieldRef Name='Title' />"+
         CAMLRowLimit: 5,
            completefunc: function (xData, Status) {
            $(xData.responseXML).find("[nodeName='z:row']").each(function() {
         var linkRows = '<li><a href="/Global/EV/Lists/Posts/Post.aspx?ID='+ $(this).attr("ows_ID") +'">' + $(this).attr("ows_Title") + "</a></li>"; 
   execPull('Jane Doe','#GCloading','#GCdisplay');   


Jun 22, 2011 at 3:44 PM


I can't really see how the items would be returned twice, unless you are calling execPull more than once. Items are only returned once in calls to GetListItems.

That said, you should really look at using a Data view Web Part (DVWP) for this. There's little value to using script in this case unless you want the list of posts you are showing to change during the page life (perhaps based on some selection by the user, for instance).

BTW, you generally want to wrap all of your script in $(document).ready(function() { rather than embedding it inside a function.


Jun 22, 2011 at 9:15 PM

Thanks Marc for your prompt reply.   As a BPOS-S customer I didn't think we had the option of using a DVWP but I am finding out ways that we can utilize it.  Looks like I have another tool to learn...  thanks again.