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

Returning GetListItems as true/false

Feb 18, 2014 at 3:43 PM
Hello again :)

I am working on a SP2010 Enterprise project for a Publishing Site Collection where I need to unbind click from links that display project information visitors don't have permission to access. All the projects are list items in a project list and there is a lookup field for it on the Team Members list. I am using the query string of the href to filter the Team Members list to verify they are associated with the project and want to return a true or false and unbind the link accordingly.

I am getting everything to work and am returning data correctly, except when I get to the SPFilterNode and I am unable to format the completefunc to return true or false/ length?
Here are my references (I just moved up to using.SPServices-0.7.2, so I may have messed something up this way as well?) :
    <script src="/sites/PublishSite/Style Library/v5/script/v5.js"></script>
    <!--[if lt IE 9]>
    <script src="/sites/PublishSite/Style Library/Scripts/html5shiv.js"></script>
    <script src="/sites/PublishSite/Style Library/v5/script/html5.js"></script>
    <script src="/sites/PublishSite/Style Library/Scripts/jquery-1.11.0.min.js"></script>
    <script src="/sites/PublishSite/Style Library/Scripts/jquery.SPServices-0.7.2.min.js"></script>
    <script src="/sites/PublishSite/Style Library/Scripts/jquery-ui-1.10.3.custom.min.js"></script>
    <script src="/sites/PublishSite/Style Library/Scripts/URI.js"></script>
    <script src="/sites/PublishSite/Style Library/Scripts/jquery.URI.js"></script>
    <script src="/sites/PublishSite/Style Library/Scripts/PublishSite.js"></script>
href sample text:
Here is my current script:
<script type="text/javascript">
$(document).ready(function() {
    var knock = $().SPServices.SPGetCurrentUser({
        fieldName: "Name"                     
        operation: "GetGroupCollectionFromUser",
        userLoginName: knock,
        async: false,
        completefunc: function(xData, Status) 
            if ($(xData.responseXML).find("Group[Name='Team Members']").length == 0 && $(xData.responseXML).find("Group[Name='Team Owners']").length == 0 )
            { alert("not in group");
                $('.Team-proj-pm-link a[href*="/sites/PublishSite/Projects/Pages/Project-Display.aspx"]').each(function() 
                    var $a = $(this);
                    function key() {                    
                        lock = $a.attr('uri:href');
                        tumbler = lock.split("=");
                        return tumbler[1];
                    var knob = key('RelProj');
                        operation: "GetListItems",
                        async: false,
                        listName: "{6F9F9311-6115-490E-BFD6-144648807A3D}",
                        CAMLQuery: "<Query><Where><And><Eq><FieldRef Name='participant' /><Value Type='String'>" + knock + "</Value></Eq><Eq><FieldRef Name='Related_x0020_Project_x003A_ID' /><Value Type='Number'>" + knob + "</Value></Eq></And></Where></Query>",
                        completefunc: function (xData, Status) {
                            $(xData.responseXML).SPFilterNode("z:row").each(function() {
                                var turn = $(this).attr("ows_Related_x0020_Project_x003A_ID")
                                if ( turn == 0) {
                                    $(this).text("- Please contact Project Manager for more information");
                                    $(this).href() == '/sites/PublishSite/Projects/Pages/Project-Display.aspx?Source=';

Feb 18, 2014 at 11:02 PM
SPFilterNode will just return all of the z:row elements from the returned XML. Do you want to just check how many items have been returned? If so, you can do:
var numItems = $(xData.responseXML).SPFilterNode("rs:data").attr("ItemCount");
Feb 19, 2014 at 4:00 AM
Edited Feb 19, 2014 at 4:01 AM
I had tried that as well after seeing the post about counting, but I apparently did something wrong when I tried to set it up. I'll give it another whack. Thanks for confirming I was barking up the right tree with that approach at least :)