Quantcast
Viewing all articles
Browse latest Browse all 6517

New Post: GetListItems variable help!!!

It looks like a scoping issue. You need to declare the variable outside the SPServices call. Something like this:
var actualStringTitle;
                $().SPServices({
                    operation: "GetListItems",
                    async: false,
                    listName: "Assigned Resource Progress Tracker",
                    CAMLViewFields: "<ViewFields><FieldRef Name='Title' /><FieldRef Name='stringTitle' /></ViewFields>",
                    CAMLQuery: "<Query><Where><Eq><FieldRef Name='stringTitle' /><Value Type='text'>"+concatstringTitle+"</Value></Eq></Where></Query>",
                    completefunc: function (xData, Status) {
                        $(xData.responseXML).SPFilterNode("z:row").each(function() {
                            actualStringTitle = $(this).attr("ows_stringTitle");
                        });
                    }
                });

 alert(actualStringTitle); 
However, you're looping through the items, so this would alert the last value. It sounds like you want to do something more like:
                $().SPServices({
                    operation: "GetListItems",
                    async: false,
                    listName: "Assigned Resource Progress Tracker",
                    CAMLViewFields: "<ViewFields><FieldRef Name='Title' /><FieldRef Name='stringTitle' /></ViewFields>",
                    CAMLQuery: "<Query><Where><Eq><FieldRef Name='stringTitle' /><Value Type='text'>"+concatstringTitle+"</Value></Eq></Where></Query>",
                    completefunc: function (xData, Status) {
                        $(xData.responseXML).SPFilterNode("z:row").each(function() {
                            var actualStringTitle = $(this).attr("ows_stringTitle");
                            alert(actualStringTitle); 
                        });
                    }
                });
This will alert every actualStringTitle from the returned list items.

M.

Viewing all articles
Browse latest Browse all 6517

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>