Quantcast
Channel: jQuery Library for SharePoint Web Services
Viewing all articles
Browse latest Browse all 6517

New Post: rs:name retrieval / ows_issues

$
0
0

The easiest way to do this is to use a method similar to what I have in roboCAML.  Here's straight from the source:

GetList = function( opt, internalUsage ) {
	//debugger;
	//Return listProperties if already cached.
	if ( listProperties[ opt.listName ] ) {
		//console.log( "returning cached results");
		//console.dir( listProperties[ opt.listName] );
		return listProperties[ opt.listName ];
	}

	if ( !internalUsage ) {
		//Determines if webURL was passed in.  Defines opt.webURL accordingly.
		//get web url, fix the yabbage if needed.
		if ( !opt.hasOwnProperty("webURL") ) {
			//use the passed in param.
			opt.webURL = GetWeb();
		}
		if ( opt.webURL.charAt( opt.webURL.length - 1 ) === "/" ) {
			opt.webURL += ajaxURL;
		} else if ( opt.webURL.length > 0 ) {
			opt.webURL += "/" + ajaxURL;
		}
	}

	//Object to be returned w/ list information
	var returnProps = {},
	 soapEnv = SOAPEnvelope.header +
	   "<GetList xmlns='http://schemas.microsoft.com/sharepoint/soap/'><listName>" + opt.listName + "</listName></GetList>" +
	   SOAPEnvelope.footer

	; //local vars

	$.ajax({
		url: opt.webURL,
		async: false,
		type: "POST",
		data: soapEnv,
		dataType: "xml",
		contentType: "text/xml;charset='utf-8'",
		complete: function(xData, Status) {
			//console.log(Status);
			//console.log(xData.responseText);
			//console.log(xData.responseXML.xml);
			$(xData.responseXML).find("Fields > Field").each( function() {
				var $node = $(this);
				//console.log( "Type: " + $(this).attr("Type") + " StaticName: " + $(this).attr("StaticName") );

				if ( $node.attr("StaticName") ) {
					returnProps[ $node.attr("StaticName") ] = $node.attr("Type");
				} else {
					//Fixed edge case when StaticName is undefined
					returnProps[ $node.attr("Name") ] = $node.attr("Type");
				}
			});
		}
	});
	return returnProps;
};

 

Above is a call to the "GetList" operation.  You can simply use SPServices to accomplish the same thing.  This will get all of the "StaticNames" from the list you want and return them when the function is complete.  You can then cache that result accordingly.

I know Marc has implemented a caching mechanism in SPServices, but I haven't had a chance to look at it in depth.  You may want to take a peek at that as well.

 

Cheers,
Matt 


Viewing all articles
Browse latest Browse all 6517

Trending Articles



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